Forums

[public API][reload] Got unexpected status code 500 OR Got unexpected status code 405

Hello! I try to use public API for reload web-app

if I use domain_name = www.{username}.pythonanywhere.com I get response:

Got unexpected status code 500: b'<html>\r\n<head><title>500 Internal Server Error</title
</head>\r\n<body>\r\n<center><h1>500 Internal Server Error</h1></center>\r\n<hr 
<center>openresty/1.15.8.3</center>\r\n</body>\r\n</html>\r\n'

If I use domain_name = {username}.pythonanywhere.com I get response: status 301 > redirect

Got unexpected status code 405: b'{"detail":"Method \\"GET\\" not allowed."}'

Can you help me to understand what I did wrong?

Thank you

Could you show the relevant bits of the code? (e.g. which API endpoint are you hitting, which method are you using, etc.)

yes, of course :) API:

response = requests.get('https://www.pythonanywhere.com/api/v0/user/{username}/webapps/{domain}/reload'.format(username=username, domain=domain),
headers={'Authorization': 'Token {token}'.format(token=token)})

Reload only accepts POST requests, not GET requests. That is shown in the API documentation

ohhhhhhhhhh THANK YOU!

Stupid, my mistake -_-

Hope that you made it work!