Thank you for the response which has been really helpful
Using your example to pick specific fields I am able to get a dictionary containing the key/value pairs for the following
- triggernumber (this is a number type in the table)
- description (type text)
- connecttime (type number)
The table has another column - servicemode - which contains text values obtained via a link to another table
When I try to add this to the dictionary I get the same error I originally had:
Cannot send a LiveObjectProxy object over HTTP as response[āservicemodeā].
You must return either Media, a string, or a JSON-compatible object (lists/dicts/strings/numbers/None).
I have done some playing about and found that the linked table value is being retrieved as a LiveObjectProxy so have converted this to a dict using the code below which outputs what I need.
@anvil.server.http_endpoint(ā/services/:idā)
def get_service_details(id):
service_row = app_tables.services.get(triggernumber=int(id))
servicemode_dict = dict(service_row[āservicemodeā])
servicemode_value = servicemode_dict[āmodeā]
return {
ātriggerā: service_row[ātriggernumberā],
āservicemodeā: servicemode_value,
ādescriptionā: service_row[ādescriptionā],
āconnecttimeā: service_row[āconnecttimeā]
}
Is this a reasonable way of getting the information or is there some easier way? - I would really like to be able to get away without manually constructing the dictionary object as this may eventually have 20+ key/value pairs.