Tfphttpclient adding post varibles lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- cpalx · 2021-08-19 17:11 Hello, using Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i HttpClient.HTTPMethod('POST', URL, SS, []);  the way add POST varibles is like this? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Params:= TStringList.Create;    Params.Values[ 'Info' ]:= '{ "tagid" : "2", "Params" : { "p0" : -1 } }';    Params.Values[ 'Header' ]:= '{ "AddDefaultParams": false, "workid": 1 }';    HttpClient.RequestBody:= TRawByteStringStream.Create(Params.Text);    Params.Free;    HttpClient.HTTPMethod('POST', URL, SS, []); ---------------------------------------------------------------------- Jurassic Pork · 2021-08-19 23:37 hello, here is an example to post json request : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button4Click(Sender: TObject);var     Client: TFPHttpClient;  Response : TStringStream;    Params : string = '{"title": "titre","body": "corps","userId": 1}';begin    Client := TFPHttpClient.Create(nil);    Client.AddHeader('User- Agent','Mozilla/5.0 (compatible; fpweb)');    Client.AddHeader('Content-Type','application/json; charset=UTF-8');  Client.AddHeader('Accept', 'application/json');    Client.AllowRedirect := true;    client.RequestBody := TRawByteStringStream.Create(Params);    Response := TStringStream.Create('');    Memo1.Clear;    try        try          client.Post('https://jsonplaceholder.typicode.com/posts', Response);          Memo1.Append('Response Code of Post Request is ' +          inttostr(Client.ResponseStatusCode));            Memo1.Append('Réponse : ' + Response.DataString);        except on E:Exception do              Memo1.Text := 'Something bad happened in Post Request : ' + E.Message;        end;    finally        Client.RequestBody.Free;      Client.Free;        Response.Free;    end;end;       Result : QuoteResponse Code of Post Request is 201 Réponse : {   "title": "titre",   "body": "corps",   "userId": 1,   "id": 101 } https://jsonplaceholder.typicode.com  is a free server to test http requests. Friendly, J.P ---------------------------------------------------------------------- cpalx · 2021-08-20 00:43 Thanks