Good morning guys. I hope you are well!
In the example below I have 2 procedures. In the procedure test_1 the StatCode is 200, so far everything is ok!, but in the procedure test_2 the
StatCode is 400 (Bad resquest).
Do I have to do any more programming to close the api calls?
procedure tform1.teste_1;
begin
try
With SslHttpRest1 Do
begin
ContentTypePost := 'application/json';
RestParams.Clear();
ExtraHeaders.Add( 'Store-Token: '+ WS_token_f);
ExtraHeaders.Add( 'Authorization: token='+ WS_token_m);
ExtraHeaders.Add( 'Authentication-Token: '+ WS_token_f );
RestParams.PContent := PContBodyJson;
StatCode := RestRequest(httpPOST, AddressWS, False, JSONObj.ToString);
lsMsg := sLineBreak +
'Headers: ' + sLineBreak +
RcvdHeader.Text + sLineBreak +
'Status code: ' + IntToStr(StatusCode) + sLineBreak +
'nStatusCode: ' + IntToStr(nStatCode);
memolog.Lines.Add(lsMsg);
end;
finally
SslHttpRest1.Close;
end;
end;
procedure tform1.teste_2;
begin
try
With SslHttpRest1 Do
begin
ContentTypePost := 'application/json';
RestParams.Clear();
ExtraHeaders.Add( 'Store-Token: '+ WS_token_f);
ExtraHeaders.Add( 'Authorization: token='+ WS_token_m);
ExtraHeaders.Add( 'Authentication-Token: '+ WS_token_f );
RestParams.PContent := PContBodyJson;
StatCode := RestRequest(httpPOST, AddressWS, False, JSONObj.ToString);
lsMsg := sLineBreak +
'Headers: ' + sLineBreak +
RcvdHeader.Text + sLineBreak +
'Status code: ' + IntToStr(StatusCode) + sLineBreak +
'nStatusCode: ' + IntToStr(nStatCode);
memolog.Lines.Add(lsMsg);
end;
finally
SslHttpRest1.Close;
end;
end;