Forums

Internal Server Error? Please how to fix?

Hi,

I am trying to run a requests.get() function within the views.py file on my PythonAnywhere Django API, and then parse the JSON as follows (NB: The pythonanywhere shown in the code is NOT my API - My API simply needs to connect to this API to also do its job, if that makes sense):

params = {'company_type': "payment"}

new_r = requests.get('http://directory.pythonanywhere.com/api/list/', json=params)

results = new_r.json()

However, the final line seems to throw an error on the server log as follows, when I connect via a client:


2018-03-14 10:27:25 Internal Server Error: /api/paymentmethods/#012Traceback (most recent call last):#012 File "/home/ll14d2f/.virtualenvs/virtualenv/lib/python3.4/site-packages/django/core/handlers/exception.py", line 35, in inner#012 response = get_response(request)#012 File "/home/ll14d2f/.virtualenvs/virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 128, in _get_response#012 response = self.process_exception_by_middleware(e, request)#012 File "/home/ll14d2f/.virtualenvs/virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 126, in _get_response#012 response = wrapped_callback(request, callback_args, callback_kwargs)#012 File "/home/ll14d2f/webapp/voo/airline/airline_app/views.py", line 204, in PaymentMethods#012 results = r.json()#012 File "/home/ll14d2f/.virtualenvs/virtualenv/lib/python3.4/site-packages/requests/models.py", line 892, in json#012 return complexjson.loads(self.text, *kwargs)#012 File "/usr/lib/ 2018-03-14 10:27:25


Anyone know what is going wrong? The code works perfectly fine when it's on a localhost, but it doesn't seem to translate well to PythonAnywhere.

Many Thanks!

It's probably this: http://help.pythonanywhere.com/pages/403ForbiddenError/

It's fixed, thanks! Simply upgraded my account!