Delphi-使用TNetHTTPRequest.Post发送JSON



var

  NetHTTPClient : TNetHTTPClient;

  parametres : TStringStream;

begin

  NetHTTPClient := TNetHTTPClient.Create(nil);

  try

    NetHTTPClient.ContentType := 'application/json';

    NetHTTPClient.AcceptEncoding := 'UTF-8';


    parametres := TStringStream.Create('[{"sku": "AS12AS11S", "estoque": 3}, {"sku": "ASKD123F4", "estoque": 10}]', TEncoding.UTF8);

    try

      Result := NetHTTPClient.Post('http://metaclients.xxx.fr/xxx', parametres).ContentAsString(TEncoding.UTF8);

    finally

      parametres.Free;

    end;

  finally

    NetHTTPClient.Free;

  end;

end;



联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678