Thank you both for your responses!
This worked perfectly! API call is returning the proper information, and canonical URL is being recorded to the table entry.
I do have another issue with regards to uploading a photo to the database and then utilizing that photo’s URL as a (string) to be passed into my API call.
After lots of reading through the forum today, I figured out how to get the URL of the media object in the table, however when I pass that URL to the “wrap” that I’m building the image doesn’t populate.
Can Anvil’s database host an image at that URL for me indefinitely for continued access? Is access restricted in any way, or does it time out? Should I use Google Drive to host the image upload/url for me?
Just to explain further, a Wrap is essentially a micro website. So the URL I’m passing is looking for an image, similar to if you used an image hosted elsewhere for building a website.
Here’s my code:
Server
@anvil.server.callable
def save_file(file):
r= app_tables.employee_data.add_row(PhotoURL=file)
return r['PhotoURL'].get_url(False)
Client (fileloader):
def file_loader_1_change(self, file, **event_args):
"""This method is called when a new file is loaded into this FileLoader"""
url= anvil.server.call('save_file', self.file_loader_1.file)
print (url)
self.text_box_5.text = url
Client (api call):
"id": "991b5d30-f897-486e-aa10-0d61ec79f827",
"data": {
"first_name": self.text_box_2.text,
"role": self.drop_down_2.selected_value,
"employee_email": self.text_box_1.text,
"phone_number": self.text_box_3.text,
"photo_url": self.text_box_5.text
}
},
{
"id": "0c72ea86-93a1-4e7d-a01a-1b871b51c97c"
}
],
}
get_wrap= anvil.server.call(
'wrapi',
payload = payload
)
print (get_wrap)
update_row = self.my_wraps.search()[0].update(CreatedAt=datetime.now(),Email=self.text_box_1.text,FirstName=self.text_box_2.text,LastName=self.text_box_4.text,Market=self.drop_down_1.selected_value,Role=self.drop_down_2.selected_value,PhoneNumber=self.text_box_3.text,WrapURL=get_wrap['canonicalUrl'])
l = list (self.my_wraps.search(tables.order_by("CreatedAt",ascending=False)))
self.repeating_panel_1.items = l
Thank you for all of your help! I’m almost completed with my first app, and I’m incredibly excited. For someone who started coding and learning Anvil 2 weeks ago, I’m amazed at my progress on this platform. I’m actually building software!