Hi, where can I find an example of how to use TScHttpWebRequest.RequestStream to transmit parameters ?
I'm using Delphi 7.
Thanks
how to POST parameters
Re: how to POST parameters
The RequestSteam property gets or sets a stream that is used to write the request data. This property can be only set if SendChunked is set to True and Method is not rmGET or rmHEAD. https://www.devart.com/sbridge/docs/ind ... stream.htm
If you mean something else, please clarify.
If you mean something else, please clarify.
Re: how to POST parameters
Four months and still no answer to the OP's question
I'm also trying to find out how to POST parameters (as content type application/json).
Simply quoting the documentation in response to a question about it isn't very helpful
I have read the documentation and find it lacking, particularly in real life examples of use.where can I find an example of how to use TScHttpWebRequest.RequestStream
I'm also trying to find out how to POST parameters (as content type application/json).
Simply quoting the documentation in response to a question about it isn't very helpful
Re: how to POST parameters
You can use code like this to show the use of this property:
Code: Select all
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
ResponseStr: string;
Stream: TFileStream;
begin
Request := TScHttpWebRequest.Create(URL);
Stream := TFileStream.Create(FileName, fmOpenRead);
try
Request.Method := rmPut;
Request.ContentType := 'application/pdf';
Request.TransferEncoding := 'binary';
Request.Headers.Add('Content-Disposition', 'form-data; name="FormFile"; filename="Document1.pdf"');
Request.ContentLength := Stream.Size;
Request.SendChunked := True;
Request.RequestStream := Stream;
Response := Request.GetResponse;
ResponseStr := Response.ReadAsString;
Response.Free;
finally
Stream.Free;
Request.Free;
end;
end;