【发布时间】:2017-04-17 14:43:34
【问题描述】:
我正在使用 Podio-js SDK 从 App Item 获取数据,将其格式化为 URL,然后将该 URL 放回同一项目的字段中。 PUT 请求要么返回一个空响应(有时说它'无法读取未定义的属性'值',或者它清空字段中的现有文本而不是更新它。我认为这与我的信息格式有关通过它。我尝试使用 {"key" : 'value'} 对语法以 JSON 对象格式格式化,但我得到了类似的结果。
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/吗?我对 item_id 特别感兴趣,出于某种原因 1。 -
@Pavlo App ID 号和 Field ID 号是从 Podio 上应用的开发者页面拉取的。 Item 的 app_item_id(在本例中为 1)被传递给函数并存储在 itemID 中。 /signup 需要一个以 app_item_id 作为请求正文的 webhook 发布请求。
-
你试过用
item_id代替app_item_id吗? -
@Pavlo-Podio 我尝试了 item id 并尝试了类似的错误消息路径,其中 item_id 为 571453849 代替了 1
-
@Pavlo-Podio 我意识到我需要摆脱 /app/17969235 部分,只需使用 /item/571453849/value/144508059/ 作为路径。但是,现在我面临着 Podio 收到请求的问题,我在我的网络表单上看到该字段已更新,但它仍然是空白的。格式化数据字符串以作为 PUT 请求中的“requestData”参数传递的正确方法是什么?谢谢!
标签: javascript podio