I am using the Podio-js SDK to GET data from an App Item, format it into a URL, and PUT that URL back into a field in the same item. The PUT request either returns an empty response (sometimes saying that it 'cannot read property 'values' of undefined, or it empties the existing text in the field instead of updating it. I think it has to do with my formatting of the information I pass it. I have tried formatting in JSON object format with {"key" : 'value'} pair syntax but I get similar results.
app.post('/signup',urlencodedParser, function(req, res) {
//gather information from the item student registry entry and format a link
//to pre-populated Podio webform
podio.isAuthenticated().then(function() {
var itemID = Object.keys(req.body)[0];
var token = podio.authObject.accessToken;
var itemPath = `/app/${creds.appID}/item/${itemID}?oauth_token=${token}`;
var fieldPath = `/item/571453849/value/signup-link`;
var link;
podio.request('GET', itemPath).then(function(responseData) {
//this request works
//console.log(JSON.stringify(responseData, null, 4));
var student = {
"studentID": responseData.app_item_id,
}
var requestData = { url: `www.example.com/${student.studentID}` }
console.log('\n');
console.log('fieldpath: ' + fieldPath + '\n');
console.log('generatedlink: ' + link + '\n');
}).catch(function(f) {
console.log(f)
})
podio.request('PUT', fieldPath, link).then(function(responseData) {
//I want to PUT this item 'link' back into a field in the same
//item, but I get the error message below
console.log(JSON.stringify(responseData, null, 4));
res.end();
}).catch(function(f) {
console.log(f)
})
})
/app/17969235/item/1/value/144508059/
from? I'm especially interested in item_id which is for some reason 1. – Pavlo - Podioitem_id
instead ofapp_item_id
? – Pavlo - Podio