gpt4 book ai didi

javascript - "Google API message ": "This API does not support parsing form-encoded input. "

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:18:56 26 4
gpt4 key购买 nike

我编写了以下 javascript 以在 google 中创建任务列表:

postData = {'title':'Netsuite List'};
access_token = 'xxxx';

url = 'https://www.googleapis.com/tasks/v1/users/@me/lists';

headers['Content-type'] = 'application/json';
headers['Authorization'] = 'Bearer ' + access_token;
headers['Content-length'] = 25;
response = $$.requestURL(url, postData, headers, 'POST');

回复说:

{ "error": 
{ "errors": [ { "domain": "global", "reason": "parseError", "message": "This API does not support parsing form-encoded input." } ], "code": 400, "message": "This API does not support parsing form-encoded input." }
}

可能的错误是什么?

最佳答案

不工作

contentType: 'application/json; charset=UTF-8',

试试这个

var headers = { };

headers["Content-Type"] ="application/json ; charset=UTF-8";
//remove to parsing form-encoded input error

data:JSON.stringify( model),
//this use for remove to parse error

例子:

$.ajax({
type: 'Post',
url: postUrl,
headers: headers,
dataType: 'json',//not required in some case
data:JSON.stringify( model),
success: function (data, sts) {
alert('success');
},
error: function (err, sts) {
var msg;
}
});

关于javascript - "Google API message ": "This API does not support parsing form-encoded input. ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17250623/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com