E
E
Ermowkin2016-04-27 23:41:47
Delphi
Ermowkin, 2016-04-27 23:41:47

How to send a Telegram API BOT file using Delphi?

I'm trying to send a file using the API. Constantly knocks out a 400 error. Tell me what I'm doing wrong?
var
Files: TIdMultiPartFormDataStream;
begin
try
Files:=TIdMultiPartFormDataStream.Create;
Files.AddFile('Document','C:\1.txt','text/plain');
THTTP.HandleRedirects:=False;
THttp.Request.ContentType := 'multipart/form-data';
THTTP.Post(' https://api.telegram.org/bot1234:XXXX/sendDocument... '+'&document', Files);
finally
Files.Free;
end;

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nllm, 2016-04-28
@nllm

send chat_id in the post-request body too.
This is most likely the problem

E
Ermowkin, 2016-04-28
@Ermowkin

Link closed. I am sending it.
The response is always the same [Error : 400 : Bad Request: there is no document in request]
As I have not tried it yet.

X
Xvir43, 2018-03-01
@Xvir43

Use NetHTTPClient and you will be happy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question