Using Google Apps Script to Post JSON Data

前端 未结 2 2109

I am trying to post JSON data to the URL from google script but getting the above error:

Server response : HTTP Status 415 - Unsupported Media Type

2条回答
  •  悲&欢浪女
    2020-12-29 10:42

    Add to your options a contentType object like this:

    var options = {
      "method": "POST",
      "contentType": "application/json",
      "headers": headers,
      "payload": payload
    };
    

    ContentType is one of the advanced parameters that the fetch method accepts. See more here.

提交回复
热议问题