Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid redirection in google-sheet app script

enter image description here

I have created a Google Sheet App Script and published as web app. https://script.google.com/macros/s/AKfycbyqUxINw93wmWPouXb7nOjt2886FBj6HBKg9sMF1B4rMN0I1xFG/exec

While i tried to POST data to this url, it's redirect to another URL. How i can avoid this redirection.?

like image 466
Eldhose Elias Avatar asked Nov 01 '25 02:11

Eldhose Elias


1 Answers

Don't use ContentService. if you are using ContentService for returning JSON data. it will redirect to another URL. That's why your are getting 302 response.

return ContentService.createTextOutput(JSON.stringify(result))
.setMimeType(ContentService.MimeType.JSON);

https://developers.google.com/apps-script/guides/content#redirects

like image 103
Eldhose Elias Avatar answered Nov 04 '25 08:11

Eldhose Elias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!