I'm trying to make a post using the IdHttp, sending data in json format, except that in every way I tested gives error on the server, the same data has successfully submitted for testing POSTMAN tool
strPost := '{...}'; //string json
xUrlPost := 'url...'; //url to post
TIdHttp configuration
IdHTTPLibSys.Request.ContentType := 'application/json';
IdHTTPLibSys.Request.AcceptCharSet := 'UTF-8';
IdHTTPLibSys.Request.CustomHeaders.Add('Authorization: Bearer xToken');
IdHTTPLibSys.Request.CustomHeaders.Add('ClientInfo: 528533378');
using TStringList
JSonToSend3 := TStringList.Create;
JSonToSend3.Add(strPost);
sHtmlResp := IdHTTPLibSys.Post(xUrlPost, JSonToSend3);
ERROR: HTTP/1.1 500 Internal Server Error
using TStringStream
JsonToSend := TStringStream.Create(strPost, TEncoding.UTF8);
sHtmlResp := IdHTTPLibSys.Post(xUrlPost, JSonToSend);
ERROR: HTTP/1.1 422 Unprocessable Entity
using TMemoryStream
JsonToSend2 := TMemoryStream.Create;
JsonToSend2.Write(strPost[1], Length(strPost) * SizeOf(strPost[1]));
JsonToSend2.Position := 0;
ERROR: HTTP/1.1 500 Internal Server Error
Recalling that the same data posted via POSTMAN (chrome) does not occur error, the json is correct, any ideas?