【发布时间】:2017-03-14 09:58:10
【问题描述】:
我正在使用 Podio,我希望能够使用 PODIO RESTful API 更新项目。
我更具体地说想将PUT 纯文本放入项目字段中。我已根据instructions 成功更新了相关字段。但是,更新会导致用“无值”更新字段。我不知道如何让 API 用我提供的值更新字段。这是我的代码:
var path = '/item/';
var item_id = 346397274;
var value = 'value';
var field_id = 108976076;
var update = "foo"
var update_length = update.length;
var options = {
'host': 'api.podio.com',
'port': 443,
'path': path + item_id + '/value/' + field_id,
'accept': 'application/json',
'method': 'PUT',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': update_length,
'Authorization': 'Bearer ' + access_token
}
}
var req = https.request(options, function(res) {
})
req.write(update);
req.end();
我想我的请求正文必须有所不同。但是我尝试了各种组合,但我无法让它发挥作用。当我运行GET 请求时,相关字段的返回数据如下:
{ status: 'active',
type: 'text',
field_id: 108976076,
label: 'Titel',
values: [ { value: 'Old Value' } ],
config:
{ default_value: null,
description: null,
settings: { format: 'plain', size: 'small' },
required: false,
mapping: null,
label: 'Titel',
visible: true,
delta: 0,
hidden: false,
unique: false },
external_id: 'titel' }
我还尝试在请求正文中添加以下内容:var update = querystring.stringify({"value": "foo"}); 和:
var update = {"values": [querystring.stringify({
"value": "foo"
})]
};
var update = querystring.stringify(update);
我做错了什么?
【问题讨论】:
标签: javascript rest https podio