[SOLVED] rest idhttp and json raw lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- superc · 2022-02-28 10:49 Hello, from postman I use an API rest passing parameter in json raw mode with no problem; in my program I use method POST with no problem passing parameter in a TStringList, but how do i pass the parameters in GET? Thanks in advance ---------------------------------------------------------------------- Remy Lebeau · 2022-02-28 18:42 Quote from: superc on February 28, 2022, 11:49:24 ambut how do i pass the parameters in GET? A GET request doesn't have any input parameters in its body, only URL query parameters. A JSON document needs to be sent using a POST or PUT request instead (depending on API).  However, TStringList is the wrong way to send JSON data, use a TStream instead, such as TStringStream. ---------------------------------------------------------------------- superc · 2022-03-02 11:31 I saw this post where the tstringlist is used https://stackoverflow.com/questions/19892471/idhttp-indy-post-do- request-parameters-with-utf-8 I use POST with Tstringlist in 'x-www-form-urlencoded' request ---------------------------------------------------------------------- Remy Lebeau · 2022-03-02 16:39 Quote from: superc on March 02, 2022, 12:31:37 pmI saw this post where the tstringlist is used ... I use POST with Tstringlist in 'x-www-form-urlencoded' request That example is not posting JSON data, though.  It is posting 'name=value' pairs in 'x-www-form-urlencoded' format.  The TStrings overload of TIdHTTP.Post() is designed for that format.  But, you cannot post JSON data in that format.  You must send the raw JSON bytes using a TStream, and you must set the Request.ContentType to a suitable JSON media type.  For example: 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 var  PostData: TStringStream;begin  PostData := TStringStream.Create('{"json":"here"}', TEncoding.UTF8);  try    IdHTTP1.Request.ContentType := 'application/json';    IdHTTP1.Post(url, PostData);  finally    PostData.Free;  end;end; ---------------------------------------------------------------------- superc · 2022-03-03 09:58 Now everything is clear, thank you again