Cannot read table row via HTTP API

Thank you for the response which has been really helpful :smiley:

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.