Javascript, Update Item field value
Can you give us an example of a properly formatted javascript request that works with the podio-js client library for updating an item's field value?
The docs essentially run in circles and looking at the ruby/php code it seems that there is an options object that is not mentioned anywhere in the js library for put requests.
Here's what I'm trying to do:
router.get('/app/put/item/field', function(req, res) {
podio.isAuthenticated()
.then(function(error, response, body) {
var requestData = {
"values": " some string 42"
};
return podio.request('put', '/item/{item_id}/value/{field_id}', requestData);
})
.then(function(responseData) {
console.log(responseData);
})
.catch(function(err) {
res.send(err);
});
});
Thanks.
-
Official comment
Hi Brian,
I can spot 2 problems with your code, so let's start with those:
#1You are returning the result of podio.request, but that will simply be undefined because it's an async operation and the result of that operation will be available to you in the callback (that you're missing there).
E.g.
podio.request('put', '/item/{item_id}/value/{field_id}', requestData, function(reponse) {
console.log('Hey there', response);
});
#2The url you're using will never work because you're not actually replacing the placeholders with real values.
Something like this will work:
var itemId = 12345;
var fieldId = 28987;
var url = '/item/' + item_id + '/value/' + field_idOr, with the new fancy ES6 syntax (note backticks and dollar signs):
const itemId = 12345;
const fieldId = 28987;
const url = `/item/${item_id}/value/${field_id}`
podio.request('PUT', url, requestData, function(reponse) {
console.log('Hey there', response);
});Hope that helps, and for future reference you can take a look at the documentation for making API requests through the podio-js client.
Comment actions -
How about for like Install Share? How do I convert this to Javascript:
PodioAppMarketShare.phpPodioAppMarketShare::install( $share_id, $attributes = array() );
I know I have to use this: /app_store/{share_id}/install
but not sure how or where to place the space_id so Podio will know in what workspace it will be installed.
Thanks in advanced!
-
You will still use a POST where `share_id` is the ID of your share (app or pack) and you can pass a payload as shown here: https://developers.podio.com/doc/app-market/install-share-22499
{
"space_id": The id of the space the shared app should be installed to,
"dependencies": The list of ids of the dependent shares that should also be installed. If not specified, all dependencies will be installed
} -
I have a sort of piggy back question related to the requestData object.
My goal is to update an item field value, in my case "lead status".
I am taking a look at the app field definitions using the developer tool for my app and see
```
"status": integer_value_of_option
```
so when i pass the request data will it be of this format ?
Please sign in to leave a comment.
Comments
4 comments