Forums

Problem with tastypie API calls?

I'm getting an error in my application when issuing an API call which works on my local machine and I believe it is something that I might have to modify to work on PA?

When going to travel.pythonanywhere.com/blogs/ for instance, it gives a ConnectionError. I'm hitting the API link which shows up in the error message to get a list of blogs. When going to the link directly (travel.pythonanywhere.com/api/v1/blog/) the data returns correctly.

Any idea why this would be happening? Is it something maybe related to needing to upgrade my account to issue requests programmatically? Thanks.

What's the API you're trying to access? Is it on our whitelist? If not, and if it's a documented public API, then maybe we can add it?

It's an API that I built, not an external API. But that's also good to know, thanks!

Just taking a look at your site, the problem seems to be that you're trying to hit an API URL on localhost:

 /home/travel/dev/main/utils.py in get_json_objects
        data = requests.get(url).json()
    ...
 Local vars
Variable    Value
url     'http://127.0.0.1:8000/api/v1/blog/'

Is that 127.0.0.1:8000 hard-coded? Because it's not going to work on PythonAnywhere....

dang, I really should have seen that without jumping to conclusions. Yes it was a problem in my settings.py that wasn't detecting the environment correctly. Thanks!

Glad to be of assistance :)