Problem with anvil.http method = PUT

Hello, I’m making a call like this:

anvil.http.request(url = url, data = {'title': 'update wordlist', 'shortdescription': '', 'longdescription': '', 'classroom_wordlist_id': 'hABNw0Jbo8WUGuIjcZWA', 'words': ['creation', 'new']}, method = "PUT", json = True)

But I’m getting back an (unspecified) http error (0, but that’s a bug report for another day).

The exact same request works perfectly off the regular python “requests” imports module when I run it from the command line. I’m not seeing anything on the server: No debug logs that the request was received, and no errors generated at run time.

PLEASE HELP!!!

Thanks,
Heidi

1 Like

Hi @heidi,

The HttpError code 0 means the browser has disallowed your request. This is likely becasue the request is being made from Form code. If you move your function to a Server Module, this should solve your problem :slight_smile:

More info in the docs here:

https://anvil.works/docs/http-apis/making-http-requests#browser-restrictions

1 Like

Yeah, but…

a) I was able to make a successful call to the EXACT SAME ENDPOINT using POST with no problem.
b) When my api returned an error code of 400 (according to my logs), anvil.http still caught it as an error of 0.