Update item field values using .Net

312 views
Skip to first unread message

Yehia Abel Salam

unread,
Jun 27, 2012, 7:26:24 PM6/27/12
to podi...@googlegroups.com
Hi,

I'm trying to update a specific field value using RestSharp and .net, however the documentation at https://developers.podio.com/doc/update-item-field-values/update-item-field-values-22367 is not very clear on the request part, can someone post how should the new value be formatted. The field to be updated is of category type, this is what i have got so far, i'm not sure about the AddParameter line.

        public IRestResponse UpdateOverallStatus(string ItemID, string SowID) {

            var request = new RestRequest();
            request.Method = Method.PUT;
            request.RequestFormat = DataFormat.Json;
            request.AddParameter("text/json", string.Format("{value: {0} }", SowID), ParameterType.RequestBody);

            request.Resource = "/item/" + ItemID + "/value/11849235?oauth_token=" + this.AccessToken;

            return fClient.Execute(request);
        }

This is the json file I recieve from GetItem, the field i want to update part
  {
         "status":"active",
         "external_id":"overall-status",
         "config":{
            "description":"Pull from AA",
            "settings":{
               "multiple":false,
               "options":[
                  {
                     "status":"active",
                     "text":"NIGO",
                     "id":1,
                     "color":"DCEBD8"
                  },
                  {
                     "status":"active",
                     "text":"Not Started",
                     "id":2,
                     "color":"DCEBD8"
                  },
                  {
                     "status":"active",
                     "text":"Prod 1.0",
                     "id":3,
                     "color":"DCEBD8"
                  },
                  {
                     "status":"active",
                     "text":"Prod 2.0",
                     "id":4,
                     "color":"DCEBD8"
                  },
                  {
                     "status":"active",
                     "text":"Prod 3.0",
                     "id":5,
                     "color":"DCEBD8"
                  },
                  {
                     "status":"active",
                     "text":"Client Review",
                     "id":6,
                     "color":"DCEBD8"
                  },
                  {
                     "status":"active",
                     "text":"Complete",
                     "id":7,
                     "color":"DCEBD8"
                  },
                  {
                     "status":"active",
                     "text":"Published",
                     "id":8,
                     "color":"DCEBD8"
                  }
               ]
            },
            "required":false,
            "mapping":null,
            "label":"Overall Status",
            "visible":true,
            "delta":1
         },
         "field_id":11849235,
         "label":"Overall Status",
         "values":[
            {
               "value":{
                  "status":"active",
                  "text":"Prod 1.0",
                  "id":3,
                  "color":"DCEBD8"
               }
            }
         ],
         "type":"category"
      } 

Thanks.

Casper Fabricius

unread,
Jun 28, 2012, 3:29:49 AM6/28/12
to podi...@googlegroups.com
Hi Yehia,

Take a look at json code example here: https://developers.podio.com/examples/items#subsection_create_item

Then, if you refer to the documentation for the different field types at the item area description (https://developers.podio.com/doc/items), you can see that a category field accepts the id of an option.

I realize that the docs are not too clear on this matter, and it's not made easier by the fact that we have recently updated the API the accept values in a simpler format, which is not reflected in the docs everywhere (the old style is still supported, though).

So, both "{value: myOptionId}" and "[myOptionId]", where you replace myOptionId with the numeric id of the option to select, is valid in this case.

Cheers,
Casper Fabricius
Developer at Podio

Yehia Abel Salam

unread,
Jun 28, 2012, 4:29:35 PM6/28/12
to podi...@googlegroups.com
thanks, but i'm getting a different error now:

{"error_propagate":false,"error_parameters":{},"error_detail":null,"error_description":"The app with id 1570909 does not have the right update on item with id 9403629","error":"forbidden"}

Although I'm sure the item is owned by this app.

My code below for reference

        public IRestResponse UpdateOverallStatus(string ItemID, string OverallStatus) {

            var request = new RestRequest();
            request.Method = Method.PUT;
            request.RequestFormat = DataFormat.Json;
            request.AddParameter("text/json", 
                string.Format("{{ \"value\": {0} }}", fOverallStatusValues[OverallStatus.ToLower()]), 

Christian Holm

unread,
Jun 28, 2012, 4:51:36 PM6/28/12
to podi...@googlegroups.com
To allow the app to update items you need to turn on the "Allow members to edit" in the app builder for the app, otherwise editing is restricted to the following:

- The creator of the item (which in this case is a user)
- The creator of the app
- The admins of the workspace

Christian
Reply all
Reply to author
Forward
0 new messages