I can't get my server app to properly receive anything.
Sender code using a design-time TIdHTTP component, with property
Request.Accept = text/html, */*
procedure TFrmTTWebserviceTester.Button1Click(Sender: TObject);
var
lJSO : ISuperObject;
lRequest: TStringStream;
lResponse: String;
begin
lJSO := SO('{"name": "Henri Gourvest", "vip": true, "telephones": ["000000000", "111111111111"], "age": 33, "size": 1.83, "adresses": [ { "adress": "blabla", "city": "Metz", "pc": 57000 }, { "adress": "blabla", "city": "Nantes", "pc": 44000 } ]}');
lRequest := TStringStream.Create(lJSO.AsString,TEncoding.UTF8); // or ASCII
// showmessage(lRequest.DataString); Correct data
IdHTTP.Request.ContentType := 'application/json';
// idHTTP.Request.Charset := 'utf-8';
lResponse := IdHTTP.Post('http://localhost:8085/ttposttest',lRequest);
// ShowMessage(lResponse.dataString);
lRequest.Free;
lJSO := nil;
end;
Receiver is a TWebAction on a TWebModule, set for MethodType mtPost (or mtAny) with handler:
procedure TWebModuleWebServices.WebModuleWebServicesTTPostTestAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var S: String;
begin
S := Request.Query;
Handled := true;
end; { WebModuleWebServicesTTPostTestAction }
Request.Query is empty.
All VCL apps. I have read these SO posts and many others but must be overlooking something...
TIA, Jan