如何使用 REST API 用新值更新字段?

How to update a field with a new value using the REST API?

我正在使用 Podio,我希望能够使用 PODIO 更新项目 RESTful API。

我更具体地想 PUT 将纯文本添加到项目字段中。我已经根据 instructions 成功更新了相关字段。但是,更新会导致用 "no value" 更新字段。我无法找到如何让 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);

我做错了什么?

请尝试以下操作:

对于请求正文:

{"titel": "My test value"}

请求 url:

https://api.podio.com/item/<item_id>/value/

全部作为 cURL:

curl 
    -H "Content-Type: application/json" 
    -H "Authorization: OAuth2 <access_token>" 
    -X PUT   
    -d '{"titel": "Some updates"}'
    https://api.podio.com/item/<item_id>/value/