ottojr 0 Posted May 17 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; Share this post Link to post
Angus Robertson 577 Posted May 17 To my eye, the two procedures seem to be identical, so I can only assume the different result is due to different parameters to the two procedures. BTW, since you are using the RawParams option in RestRequest, RestParams are ignored. Angus Share this post Link to post