How to use ContentService and doPost to create a REST API

后端 未结 1 1765
南旧
南旧 2021-01-15 21:24

I want to have the myFunction() send a payload which will be processed by the doPost and return some content based on the payload. I can only get these test scripts to work

相关标签:
1条回答
  • 2021-01-15 21:33

    The problem appears to be that the domain "script.googleusercontent.com", which is where ContentService content is served from, doesn't allow the POST method. When your doPost() handler returns the TextOuput it sends a redirect back to the client, which causes the client to send the POST again to script.googleusercontent.com, which is not allowed.

    If you can use GET then that would be the recommended solution. If not, you may need to split the work into two parts: first POSTing with no response, then GETting to retrieve the response.

    Update: As of Sept 21, 2012 this problem should now be fixed, and you can POST to the URL without any errors.

    0 讨论(0)
提交回复
热议问题