M
M
mainentrypoint2020-02-02 20:55:34
css
mainentrypoint, 2020-02-02 20:55:34

How to correctly send the body in a POST request?

Hello!

Please tell me how can I change this query:

GET https://api.telegram.org/key/getUpdates?limit%3D10... HTTP/1.1
HOST: api.telegram.org
Connection: Keep-Alive


In another, where instead of the GET method, there will be POST. I tried to solve the problem in this way:

POST https://api.telegram.org/key/getUpdates HTTP/1.1
HOST:api.telegram.org
Connection: Keep-Alive
Content-Length: 40

limit%3D100%26offset%3D0%26timeout%3D300


However, the server does not understand me and does not accept the arguments in the request body and immediately issues a response (although it should be long-polling)
All data in the body is converted to urlencode
Please tell me, maybe you need to add parameters to the header, I can’t formulate a question for Google

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SagePtr, 2020-02-02
@mainentrypoint

They also forgot to specify the header:
Content-Type: application/x-www-form-urlencoded
The server must know what format the request body is in (although it can try to guess, but why should it play a guessing game?)

P
Page-Audit.ru, 2020-02-02
@PageAuditRU

So try not to encode, but just pass the string "limit=100&offset=0&timeout=300" in the post
Content-Length: 31

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question