我试图将action_fields中的数据作为查询字符串添加到bundle.request.url中。这是原始包数据
{
"auth_fields": {
"sub_domain": "abc",
"apiKey": "1234"
},
"request": {
"files": {},
"url": "https://abc.my.workfront.com/attask/api/v7.0/project?&method=post",
"headers": {
"Content-Type": "application/json; charset=utf-8",
"Accept": "application/json"
},
"params": {
"apiKey": "1234"
},
"data": "{\"status\": \"PLN\", \"name\": \"Test 2\"}",
"method": "POST"
},
"action_fields": {
"status": "PLN",
"name": "Test 2"
},
"action_fields_full": {
"status": "PLN",
"name": "Test 2"
},
"meta": {
"frontend": false
},
"action_fields_raw": {
"status": "PLN",
"name": "Test 2"
},
"url_raw": "https://{{sub_domain}}.my.workfront.com/attask/api/v7.0/project?&method=post",
"zap": {}
}
我正在使用Zapier提供的示例,并提出了这个
'use strict';
var Zap = {
project_pre_write: function(bundle) {
// bundle.request.method = "POST";
console.log(bundle.request.action_fields["status"]);
bundle.request.url = "http://abc.my.workfront.com/attask/api/v8.0/project?method=post";
bundle.request.params = $.param(bundle.request.action_fields);
console.log(bundle.request.params);
return bundle.request;
}
};
但是我抛出了这个错误
TypeError: Cannot read property 'jquery' of undefined:
我没有Javascript专家(几乎不是用户)所以任何想法都会受到赞赏。最终结果应如下所示
http://abc.my.wrokfront.com/attask/api/v7.0/project?method=post&name=Test%202&status=PLN&apiKey=1234
答案 0 :(得分:0)
试试这个:
i