I had copy this code for send a json in a server web,
https://wiki.freepascal.org/fphttpclient#Posting_JSONbut when compiled I have this error
"unit1.pas(44,27) Error: Identifier not found "TRawByteStringStream""
but this class uses Classes and I have in my uses....
where is the problem?
I use Lazarus 2.0.6
var
Client: TFPHttpClient;
Response : TStringStream;
Params : string = '{"title": "Some New Note","content": "This is awesome stuff in the new note"}';
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.UserName:=USER;
//Client.Password:=PW;
client.RequestBody := TRawByteStringStream.Create(Params);
Response := TStringStream.Create('');
try
try
client.Post('TheURL', Response);
writeln('Response Code is ' + inttostr(Client.ResponseStatusCode)); // better be 200
except on E:Exception do
writeln('Something bad happened : ' + E.Message);
end;
finally
Client.RequestBody.Free;
Client.Free;
Response.Free;
end;