podio

Podio API: Modifying an item with appId and appItemId


EDIT: I have figured out that I was trying to update by using appItemId (local for the app) in the ItemId field (global). The question now is how to update without using the global ItemId.

I have setup a script to authenticate as an app.

I can script fetching and creating new items no problem, but I can't edit or delete existing items. From the error message I can gather that the app does not have permissions to modify its own items.

How do I add those permissions?

So, this works:

var item = new Item();
item.Field<TextItemField>("title").Value = "blah";
podio.ItemService.AddNewItem(appId,item);

This doesn't:

var item = new Item { ItemId = 1 };
item.Field<TextItemField>("title").Value = "blah";
podio.ItemService.UpdateItem(item);

Solution

  • I found a way to do it by first fetching the item by appItemId and then updating it.

    var item = podio.ItemService.GetItemByAppItemId(appId, appItemId);
    item.Field<TextItemField>("title").Value = "ayyyy";
    podio.ItemService.UpdateItem(item);
    

    This works, although requires an additional GET request.

    EDIT: The code before might not even work in all cases. So I had to do:

    var item = new Item { ItemId = podio.ItemService.GetItemByAppItemId(appId, appItemId).ItemId};
    item.Field<TextItemField>("myval").Value = "test";
    podio.ItemService.UpdateItem(item, null, null, true);
    

    because something breaks when updating with all the other values.