What I’m trying to do:
I’m trying to create an API server, with an endpoint that can accept a list of dictionaries.
What I’ve tried and what’s not working:
I’ve tried using @anvil.server.http_endpoint
, which was working well for simple input types (string, numbers, etc.), but is failing when I try to send a list of dictionaries.
Code Sample:
@anvil.server.http_endpoint('/v1/check')
def v1_check(english_translation='', english_sentence='', possible_mistakes=None):
"""
I need possible_mistakes to accept a list of dictionaries.
"""
Workaround:
For now, I changed possible_mistakes to accept a string, and then on the server-side, I’m decode using json.loads(possible_mistakes)
to convert it to a list of dictionaries.
But this feels like a hack… Is there a better way to do this?