HttpPost (TJson)
<source lang="delphi">function (const iServiceProvider:string; const iUrl:string; var jsonR:TJson):integer;</source>
Cette fonction exécute une requête POST sur un service REST et retourne la réponse dans la variable jsonR.
Paramètre | Usage |
---|---|
iServiceProvider | Nom du fournisseur de service utilisé pour configurer la requête |
iURL | URL relative à l'URL du fournisseur de service |
jsonR | Objet jsonR recevant la réponse |
Exemples:
<source lang="delphi">
var jsonQ,jsonR:TJson; rslt:Integer; AStr:string; begin
jsonQ := Tjson.Create('{....}'); // rslt := jsonQ.httpPost('myServiceProvider','/myapi/myressource',jsonR);
if Assigned(jsonR) then begin // response has a json payload ShowMessage(Format('HTTP: %d %s',[rslt, jsonR.AsString)); end else begin // response has no json payload ShowMessage(Format('HTTP: %d %s',[rslt, jsonQ.httpResponseText)); end;
end;
</source>
Voir aussi: