Jump to content

ottojr

Members
  • Content Count

    4
  • Joined

  • Last visited

Everything posted by ottojr

  1. 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;
  2. ottojr

    Parameter passing

    Good afternoon people. How do I write in the head of the request to send a key as shown in the example below? I would like to thank you for any help. I'm trying like this: SslHttpRest.RestParams.AddItem('Store-Token', '123456789x'); Here I am using POSTMAN object(Slim\Http\Headers)#302 (1) { ["data":protected]=> array(9) { ["Content-Type"]=> string(16) "application/json" ["Content-Length"]=> string(0) "" ["Store-Token"]=> string(32) "22345673301244567896663456789012" ["User-Agent"]=> string(21) "PostmanRuntime/7.37.3" ["Accept"]=> string(3) "*/*" ["Postman-Token"]=> string(36) "40f28212-2f71-487a-a22f-d6ecdfa61b8b" ["Host"]=> string(14) "localhost:8080" ["Accept-Encoding"]=> string(17) "gzip, deflate, br" ["Connection"]=> string(10) "keep-alive" }} Here I am using the "TSslHttpRest" component and I need the key "["Store-Token"]" object(Slim\Http\Headers)#302 (1) { ["data":protected]=> array(7) { ["Content-Type"]=> string(16) "application/json" ["Content-Length"]=> string(0) "" ["Accept"]=> string(30) "application/json;charset=UTF-8" ["Connection"]=> string(10) "keep-alive" ["Accept-Encoding"]=> string(13) "gzip, deflate" ["User-Agent"]=> string(110) "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" ["Host"]=> string(14) "localhost:8080" } }
  3. ottojr

    Parameter passing

    Thank you everyone for helping. It worked here! 🤜🤛 🤝
  4. ottojr

    Parameter passing

    I'm using Delphi 10.3 I am sharing the source code as an attachment Robertson, i try ExtraHeaders.Add, but it did not work procedure TSnippets.doHttpRestReqCl.txt
×