Cryptic Error Message In API When Returning HTTP Response

edit - I have edited this down to be more succinct.

If I do this in an http endpoint -

return anvil.server.HttpResponse(201,"OK")

I get this in my app log -

Incoming API request from Zurich, Switzerland.
TypeError: list indices must be integers or slices, not str at /downlink/anvil/_server.py, line 1130called from /downlink/anvil/_server.py, line 1176

It gives me no idea where in the server function the error occurs, I worked it out through trial and error.

What am I doing wrong?

I’ve worked around it by doing this, which I believe equates to the same thing -

return "HTTP/1.1 201 Created\n\n"

Thanks David, that was a bug in our code that showed its face when you use enable_cors=True and construct an HttpResponse.

We’ve squatted it now, can you let me know if it’s fixed for you?

1 Like

Hi - yes, that seems fixed.

Though I would have gone to court and sworn that I tried it without the enable_cors parameter, but I guess I didn’t…

Cheers!

1 Like