在 C# .Net 中使用 Podio API 更新 Podio 项目

Updating Podio Item using Podio API in C# .Net

我是跑道的新手,在 c# .net 中使用跑道 API。我能够获取项目集合,使用 API 和 .Net 中的 webhook 创建项目。但我坚持更新项目。我在 ITEMX.Update 的项目更新上使用 webhook。 但是我在更新项目时遇到错误。

在测试时我已经尝试过,

但还是报错。 错误消息的最后一句话是:

"\\"item_id\": 99999999, \\"revision\": 0} (object): 必须是整数\",\"request\":{\"url\":\"http://api.podio.com/item/9999999\",\"query_string\":\"\",\"method\":\"PUT\"}}"}

我尝试了很多事情并查阅了很多文档,但没有找到解决方案。 有人可以帮忙完成吗?

'

  public static async Task<int> UpdateCalculationsInGMApp(int appItemId)
{
    //Get related GMApp

    try
    {
        var _Podio = new Podio(Helper.ApiClientId, Helper.ClientSecret);
        AppMaster Ratesapp = Helper.GetAppToken("Costing Rates", "VikramTestWS");
        await _Podio.AuthenticateWithApp(Ratesapp.AppId, Ratesapp.Token);

        Item ratesPodioItem = await _Podio.ItemService.GetItem(appItemId);
 //Item fetched successfully here
        //thentried to set one of the field with new value. Later on commented and tested but didn't worked
        //var pm_Rate = ratesPodioItem.Field<NumericItemField>("pm-rate");
        //pm_Rate.Value = 100;

        try
        {
            int x = (int)await _Podio.ItemService.UpdateItem(ratesPodioItem, null, null, true, true);
        }
        catch (Exception excp)
        {
            Logger.AddToLog(DateTime.Now, excp.Message, "Error: updating podio item" + ratesPodioItem.ItemId.ToString());
        }
    }
}'

您可能正在使用获取的项目对象本身来更新回跑道。这是行不通的。您需要创建一个全新的 Item 对象并执行更新工作。请参阅此处的文档:http://podio.github.io/podio-dotnet/items/

  1. 创建新项目,而不是检索和更新现有项目!

  2. 将 ItemId 设置为您要更新的项目的 ID。

  3. 将要更新的任何字段设置为新项目。

  4. 更新那个新项目。

    Item itemToUpdate = new Item(); itemToUpdate.ItemId = appItemId; // 您需要更新的项目的 item_id。 var textfield = itemToUpdate.Field("notes-text"); textfield.Value = "更新测试" + DateTime.Now.ToShortDateString();

         try
         {
             int x = (int)await _Podio.ItemService.UpdateItem(itemToUpdate , null, null, true, true);
         }
         catch (Exception excp)
         {
             Logger.AddToLog(DateTime.Now, excp.Message, "Error: updating podio item" + ratesPodioItem.ItemId.ToString());
         }