1
I am trying to make a POST type request using the components: Resrrequest, Restclient, Restresponse by Delphi Xe8.
In the GET type integration I can do normally, I get the return normally from the server.
However, when doing the integration via POST is giving an exception in the execution: "Execution of request terminated with Unknown error".
Maybe I’m missing something. The server expects 2 parameters:
1 - HeaderParam, tipo AlfaNumérico, Identificador "Token-Integracao"
2 - BodyParam, tipo Complexo, Identificador "itensResolvidos"
Follow the code I’m using to do the integration:
with fDm do
begin
sRet := EmptyStr;
RESTClient.BaseURL := sInfo[7];
RESTClient.Params.ParameterByName('Token-Integracao').Value := sInfo[6];
with RESTClient.Params.AddItem do
begin
name := 'itensResolvidos';
Value := sJson; // String com o JSON a ser enviado, montado anteriormente
Kind := TRESTRequestParameterKind.pkREQUESTBODY;
end;
RESTRequest.Method := rmPOST;
RESTRequest.Execute; // Aqui dá a Excessão e não continua o programa
sRet := '{"retorno":' + RESTResponse.JSONValue.ToString + '}';
end;
For the token you have to create a header type parameter, do the same as you did to create the parameter for solved items only in type choose pkHTTPHEADER. Because the return waits for the token via header.
– Jefferson Rudolf
The token I created directly in the component, because I’m using the Restclient component to make the GET, and it worked. Still I will do what you said, create the same way as the other to see if this is it. Thank you!
– Rodrigo Tognin
Anything, try to take the test for Postman
– Jefferson Rudolf
I put the Token the same way, did not solve. I’m going to test by Postman. Thanks!
– Rodrigo Tognin