4

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.?

0

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

6 Comments

did you write a doPost(e) method?
@Aerials Yes.. I'm using doPost(e) function
Is there another alternative/work around ? if someone doesn't need to use redirection?
@DimitrisTsarouhas you can use HTMLService
@newbie, I tried that and got a bunch of html and javascript and not the content I entered into HtmlService.createHtmlOutput()
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.