0

I am using Requests to communicate with a simple api.

The code looks like this:

payload = {'text': reply, 'name': varname, 'avatar': varavatar}
r = requests.get('http://example.de/create.json', params=payload)

However, the result looks like this:

{"result": "error", "error": "error_no_direct_connection"}

This might be a problem with the api but I'm not sure. So I printed out the URL that Requests created (print r.url). It looks like this: http://url.com/create.json?text=Test&name=myname&avatar=http%3A%2F%2Fa0.url.com%2Fnormal.png

To make sure it's not a problem oft the api I tried it with curl. The command works!

curl --data-urlencode "text=Test" -d "name=myname" -d "avatar=http://url.com/normal.png" http://url.com/create.json

1 Answer 1

1

The curl option --data causes curl to submit a POST request, not a GET request. Try request.post(..., data=...).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.