【问题标题】:Updating Podio Item using Podio API in C# .Net在 C# .Net 中使用 Podio API 更新 Podio 项目
【发布时间】:2016-12-14 11:53:50
【问题描述】:

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

虽然我尝试过测试,

  • 为字段分配新值。
  • 刚刚使用 ItemId 获取项目并立即调用 ItemUpdate() 方法对获取的项目没有任何更改

但仍然出现错误。 错误信息的最后一句说:

"\\"item_id\\": 99999999, \\"revision\\": 0} (object): 必须是整数\",\"request\":{\"url\":\"http://api.podio.com/item/9999999\",\"query_string\":\"\ ",\"方法\":\"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());
        }
    }
}'

【问题讨论】:

  • 您能否提供您的源代码(当然没有任何访问令牌和登录名/密码),以便更容易理解出了什么问题?

标签: c# podio


【解决方案1】:

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

【讨论】:

  • 嗨,Ajmal,非常感谢。你说的对。我们需要有一个全新的项目来更新。成功了!!!!!!
【解决方案2】:
  1. 与其检索和更新现有项目,不如创建一个新项目!

  2. 将 ItemId 设置为要更新的 Item 的 id。

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

  4. 更新那个新项目。

    项目 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());
         }
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多