Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 14 of 14 total
Thread Trying to connect to REST server
Mon, Sep 13 2021 11:11 AMPermanent Link

Michael Saunders


Have you verified that the web server on their end is actually returning a Content-Length header in the response ?

After a   successful  post as follows

case Request.StatusCode of
   HTTP_FORBIDDEN:
      PalletWaysresponse := ('Request 403 Error. Data = ' +  Request.ResponseContent.Text);
   HTTP_OK:
        PalletWaysresponse := (inttostr(Request.RequestHeaders.count) +  '     ' +  Rquest.ResponseContent.Text);
   else
     PalletWaysresponse := ('Other result. StatusCode = ' + IntToStr(Request.StatusCode) + '. Response  Data = ' +
                 Request.ResponseContent.Text);
 end;

I get the following response:

0       {
   "Status": {
       "Code": "OK",
       "Description": "Successful"
   },
   "Detail": {
       "Message": "No data has been committed as it was not requested."
   }
}

ie Request.RequestHeaders.count passes back 0  Is this what you want ? If not please explain what I need to do

Do you have these reversed ?  I was under the impression that the problem you were having was with the server application's TServerRequest execution, not the opposite.

The error occured when running the code from the server (initiated from the client) as per my first post  I then altered it as per Raul's suggestion and it then worked OK  According to Raul I ought to be able to also run this code from the client only (no server ) so I then used Raul's  code to test this  but it failed

Mike
Tue, Sep 14 2021 8:35 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< After a   successful  post as follows >>

Is that a successful post from a *client* application, or a *server* application ?

<< ie Request.RequestHeaders.count passes back 0  Is this what you want ? If not please explain what I need to do >>

No, that property is for the request and not used with the response.

Can you send me the source code to the server application that you're using along with any API keys, etc. that I would need to make the request ?  I need to test this here to see exactly what's going on before I try to fix it.  I suspect that the HTTP request client for server applications is being too aggressive about requiring a Content-Length header in certain cases, but I need to be sure.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Sat, Sep 18 2021 9:26 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

Per email:

The error that you're getting is a CORS (Cross-Origin Resource Sharing) error.  This is because you're loading the application from localhost/your web server, but making a request to the Palletways API, which is on a different web server.

More information:
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Unfortunately, there's no way to correct this because it's an issue between the browser and the Palletways web server.  The browser will always send CORS headers and abide by whatever the Palletways web server responds with in terms of allowing/disallowing the cross-origin request.  This is why the server application's request works - the server application's request doesn't send CORS headers because it doesn't care about CORS (it's secured as part of the web server security and execution privileges that you can set up) and can make calls to any web server without issue.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Sep 29 2021 11:41 AMPermanent Link

Michael Saunders

Just for the record the code as per my first post does work when executed from the server   Not sure how I managed to generate that program exception
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image