0
votes

I have a google app script deployed as a web app with doPost() handler . The handler function exposes a sort of remote procedure call functionality , and allows my embedded iot devices to POST parameters as a client , and receives status values , both in JSON format . I use bare metal C resources to do so , i.e. I implement basic HTTP POST request protocol on top of the TCP socket.

The POST request is straight forward , the doPost() handler is called , and it updates my Google Sheet with the send JSON parameters. The status of the app function ("OK" / "FAILED") is then returned to the client . Here is where things went south for me. The client , instead of receiving the POST response , receives a HTTP 302 redirect URL https://script.googleusercontent.com/xxxx with URL parameters . I now need to start an HTTP GET session with the new url, and then I receive the desired original POST response.

So it actaully works , and quite reliably so . But , what is the reason for that complicated redirection with a subsequent GET request ? Is it normal behavior , or am I overcooking / undercooking something , I am an embedded engineer , and therefore knowledge of HTTP is limited. Have I left a POST Header out in the original POST request .? I only support Content-Type and Content-Length in terms of the POST method.

Thanking you in advance.

1
While I see you have already solved your issue, would you consider providing the code related to the HTTP request/s you are making, so that your situation can be understood?Iamblichus

1 Answers

0
votes

I have found an answer after struggling in the Google documentation:

Redirects:

For security reasons, content returned by the Content service isn't served from script.google.com, but instead redirected to a one-time URL at script.googleusercontent.com. This means that if you use the Content service to return data to another application, you must ensure that the HTTP client is configured to follow redirects. For example, in the cURL command line utility, add the flag -L. Check the documentation for your HTTP client for more information on how to enable this behavior.

Reference: