ziolko / spreadapi

Free REST API for Google Spreadsheet
https://spreadapi.roombelt.com
Other
87 stars 13 forks source link

Getting Moved Temporarily 302 #1

Closed PierrickLozach closed 4 years ago

PierrickLozach commented 4 years ago

Hi,

great idea!

I have one issue. When I call the POST /exec from Postman, it works fine but from other clients (e.g. vscode REST client), I get a 302 Moved Temporarily error.

Request from VS Code REST Client addon:

POST https://script.google.com/macros/s/AKfycbwb6hPJrEOQEqNsjGnSzdlGdhDcd2EXj5yikvOA_H9ihwAWtHE/exec HTTP/1.1
content-type: application/json

{
    "sheet": "Sample POC Data",
    "key": "<KEY HERE>"
}

I get this:

HTTP/1.1 302 Moved Temporarily
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Date: Thu, 05 Dec 2019 08:45:46 GMT
Location: https://script.googleusercontent.com/macros/echo?user_content_key=GVQyW_b65XMDMRb0c05WbTG8LR-Cg3p40p4IDcritM1YMHb-SaOrNLlo08h7oTh8fCU8xJ6UKZKqII0FqeGrH0yGE8MAsj0km5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnNrBxTLIR-OmuNHHNkCylqmg0bzgBRVsbxJtmTQPCEGHgiNvdOheAhNkiN6ji3JQ_qOIp7sEUsJ2&lib=MgGipqB0Vlrps_mc891bgMHc7neZF186U
Content-Encoding: gzip
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
Connection: close
Transfer-Encoding: chunked

<HTML>
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A HREF="https://script.googleusercontent.com/macros/echo?user_content_key=GVQyW_b65XMDMRb0c05WbTG8LR-Cg3p40p4IDcritM1YMHb-SaOrNLlo08h7oTh8fCU8xJ6UKZKqII0FqeGrH0yGE8MAsj0km5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnNrBxTLIR-OmuNHHNkCylqmg0bzgBRVsbxJtmTQPCEGHgiNvdOheAhNkiN6ji3JQ_qOIp7sEUsJ2&amp;lib=MgGipqB0Vlrps_mc891bgMHc7neZF186U">here</A>.
</BODY>
</HTML>

Still works from Postman though:

screenshot

Any idea why this is happening?

ziolko commented 4 years ago

Hi @PierrickI3,

This is actually the expected behavior. Google Apps Scripts first return 302 (redirect) which means something along the lines "this resource is available on another location - go and check there".

Browsers and most rest clients simply follow redirect to get the actual response. E.g. VS Code REST Client has a setting rest-client.followredirect to configure that (https://marketplace.visualstudio.com/items?itemName=humao.rest-client#user-content-settings).

Let me know if this helps! Mateusz

PierrickLozach commented 4 years ago

Thanks @ziolko !