小编Shi*_*lpi的帖子

使用Google Apps脚本发布JSON数据

Server response  :  HTTP Status 415 - Unsupported Media Type
Run Code Online (Sandbox Code Playgroud)

我试图从谷歌脚本发布JSON数据到URL,但得到上述错误.这是我的代码:

function myFunctionpost() {
  var url = "http://abc.xyz.org/jira/rest/api/2/issue";
  var data = {"project":{ "key": "KEY"},"summary": "create issue.", "description":                 "Creating of an issue from google spreadsheet using the REST API", "issuetype": {"name": "Bug"}}  ;
   var payload = JSON.stringify(data);

   var headers = { "Accept":"application/json", 
              "Content-Type":"application/json", 
              "Authorization":"Basic _authcode_"
             };

   var options = { "method":"POST",
                "headers": headers,
                "payload" : payload
               };
   var response = UrlFetchApp.fetch(url, options);
 Logger.log(response);  

 }
Run Code Online (Sandbox Code Playgroud)

我尝试更改内容类型但没有工作.auth代码正常工作,因为我能够从URL获取.

有人知道我哪里出错吗?谢谢.

json content-type jira http-post google-apps-script

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

content-type ×1

google-apps-script ×1

http-post ×1

jira ×1

json ×1