I have a IdHTTPServer in delphi indy and I want to recieve a json that is send in the body.
I have this:
procedure Treportserver.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
ctxt, json,msg : string;
inifile : TStringList;
Stream : TStream;
S : string;
begin
if(ArequestInfo.Document = '/favicon.ico') then
with AResponseInfo do
begin
ContentType := 'text/plain; charset=utf-8';
ContentText := '';
WriteHeader;
WriteContent;
exit;
end;
//LOGS('Document => '+ARequestInfo.Document);
//ctxt := ARequestInfo.FormParams;
If ARequestInfo.CommandType = hcPOST then
begin
Stream := ARequestInfo.PostStream;
if assigned(Stream) then
begin
Stream.Position := 0;
S := UTF8ToAnsi(ReadStringFromStream(Stream));
end;
end;
ctxt := ARequestInfo.Params.Values['report'];
LOGS('Petición Recibida. Reporte => '+ctxt);
json := GetPDF(ctxt);
with AResponseInfo do
begin
ContentType := 'text/plain; charset=utf-8';
ContentText := json;
WriteHeader;
WriteContent;
end;
end;
I don't know how to get the json body send by postman in this case.