tjespe
tjespe

Reputation: 702

Unable to send POST request to Google Apps Script

I have a Google Apps Script that is supposed to receive and process base64-encoded data. Sending CORS GET requests to it works well, but the data strings are too long to be sent as GET parameters, so I have to send it in CORS POST requests. Unfortunately, all POST requests to the script gets HTTP 405 and does not include the access-control-allow-origin:*-header.

This is an excerpt of my current server side script:

function doGet(e) {
   // Irrelevant because GET requests works fine
}

function doPost(e) {
  // Doesn't work:

  Logger.log(e);
  return ContentService.createTextOutput("It works!");
}

I am using angularJS on the client side to send the requests, here is a screenshot from Chrome of a request: enter image description here

Is there anything I can do to fix this?

Upvotes: 1

Views: 1810

Answers (1)

tjespe
tjespe

Reputation: 702

For some reason it got solved when I added the header Content-Type: undefined to the request.

Upvotes: 1

Related Questions