Reputation: 2850
I am using Podio and I want to be able to update items using the PODIO RESTful API.
I more specifically want to PUT
plain text into an item field. I have successfully updated the field in question in accordance with the instructions. However the update results in updating the field with "no value". I cannot find out how to get the API to update the field with the value I provide. This is my code:
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();
I guess that my request body some how has to be different. But I have tried all kinds of combinations and I just can't get it to work. When I run a GET
request the returned data for the field in question are as follows:
{ 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' }
I also tried putting the following in the request body: var update = querystring.stringify({"value": "foo"});
and:
var update = {"values": [querystring.stringify({
"value": "foo"
})]
};
var update = querystring.stringify(update);
What am I doing wrong?
Upvotes: 1
Views: 3222
Reputation: 2013
Please try following:
For request body:
{"titel": "My test value"}
For request url:
https://api.podio.com/item/<item_id>/value/
All together as 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/
Upvotes: 4