M
M
Marat_RD2017-02-22 13:39:59
Python
Marat_RD, 2017-02-22 13:39:59

Problem when sending a POST request in python?

Hello! I'm trying to send a post request.
Here is the post request:

POST /token HTTP/1.1
Host: oauth.yandex.ru
Content-type: application/x-www-form-urlencoded
Content-Length: <request body length>
[Authorization: Basic <encoded string client_id:client_secret>]
grant_type=authorization_code
& code=<verification code>
[& client_id=<app id>]
[& client_secret=<app password>]
[& device_id=<device id>]
[& device_name=<device name>]

Here is the code:
payload = ({"grant_type":"authorization_code","code" : message.text, "client_id":const.idApps_Yand,"client_secret":const.passApp_yand,"device_id": const.UUID, "device_name":const.divace_name}) 
headers = {"Host": "oauth.yandex.ru","Content-type": "application/x-www-form-urlencoded", "Content-Length":"2"}
 r = requests.post(url=URL,data=payload,headers=headers)

But the error takes off:
What does it mean? And how to fix it?
Thank you all in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Axian Ltd., 2017-02-22
@AxianLTD

Python IMHO has nothing to do with it. The message clearly contains an indication of the error
"Bad Request: message is too long" - Too large request in the POST message
Increase the size of accepted POST messages on the server side.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question