Error reading App reference field from items using .NET API

Comments

13 comments

  • Official comment
    Casper Fabricius

    I've investigated some more, and yes, we have changed something internally so that file attachments are now included in the data for items referenced in app ref fields. We didn't expect adding more data to break any client, but the .NET client is unfortunately not very flexible.

    The current .NET client is user contributed and as such not officially supported or maintained by us. We are working on a new .NET client that will be released shortly. For that reason we are not going to provide a fix for the current client, but you are much welcome to fix it yourself and submit a pull request to get the fix merged into the client.

    Comment actions Permalink
  • Mark Broomfield

    I too have started receiving this exact same error.

    Seems to appear when there are no files attached to an app item.

    Any help would be really appreciated.

    Thanks
    Mark

    0
    Comment actions Permalink
  • Shivakumar Krishnamurthy

    (Sorry I meant September 2013 in my post)

    0
    Comment actions Permalink
  • Amy Chung

    I have the same problem started few days ago. Any help will be appreciated.

    0
    Comment actions Permalink
  • Casper Fabricius

    Can each of you that have this problem please provide some more information?

    1) What exact API call you make? (Please include the code for the call, and the item or field ids you are using)

    2) On exactly what line does the error occur, and what is the full stacktrace?

    0
    Comment actions Permalink
  • Shivakumar Krishnamurthy

    Hi Casper,

    My objective is to read the item ids from the app reference field of each item.

    The key issue is in line number 7 and 8. “appref” all these days had an enumerable member (appref.Items) which would have a list of each “ItemId” in that field.
    The code below worked perfectly fine since September 2013, but started throwing exceptions until last week.

    1 private string GetStringValueforField(Podio.API.Model.Item podItem, ItemField field)
    2 {
    3 string sValue = "";
    4 switch (field.Type)
    5 {
    6 case "app":
    7 var appref = podItem.Field<AppItemField>(field.ExternalId);
    8 var apprefitems = appref.Items;
    9 foreach (var item in apprefitems)
    10 {
    11 if (!string.IsNullOrEmpty(sValue)) sValue += ";";
    12 sValue += item.ItemId;
    13 }
    14 break;
    . . .
    . . .
    . . .

    Here is the stack and the exception that is thrown-

    System.ArgumentException was unhandled
    _HResult=-2147024809
    _message=Object of type 'Newtonsoft.Json.Linq.JArray' cannot be converted to type 'System.Collections.Generic.List1[Podio.API.Model.FileAttachment]'.
    HResult=-2147024809
    IsTransient=false
    Message=Object of type 'Newtonsoft.Json.Linq.JArray' cannot be converted to type 'System.Collections.Generic.List
    1[Podio.API.Model.FileAttachment]'.
    Source=mscorlib
    StackTrace:
    at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
    at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
    at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
    at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
    at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
    at ObjectExtensions.objectFromDict(Object someObject, IDictionary2 source)
    at ObjectExtensions.As[T](IDictionary
    2 source)
    at Podio.API.Model.ItemField.valueAsT
    at Podio.API.Model.ItemField.valuesAsT
    at Podio.API.Utils.ItemFields.AppItemField.get_Items()
    at LCMMetrics.PodioAppSvc.GetStringValueforField(Item podItem, ItemField field) in c:\Users\shivakumark\Documents\Visual Studio 2012\Projects\LCMMetrics\LCMMetrics\PodioAppSvc.cs:line 304
    at LCMMetrics.PodioAppSvc.ConvertItemtoNameValuePairs(Item podItem) in c:\Users\shivakumark\Documents\Visual Studio 2012\Projects\LCMMetrics\LCMMetrics\PodioAppSvc.cs:line 388
    at LCMMetrics.TaskManager.RunMetrics() in c:\Users\shivakumark\Documents\Visual Studio 2012\Projects\LCMMetrics\LCMMetrics\LCMMetrics.cs:line 254
    at LCMMetrics.LCMMetrics.Main(String[] args) in c:\Users\shivakumark\Documents\Visual Studio 2012\Projects\LCMMetrics\LCMMetrics\LCMMetrics.cs:line 501

    Thanks for helping with this.

    -Shiva

    0
    Comment actions Permalink
  • Casper Fabricius

    You still haven't told me what API call you make. I understand that the error does not happen when the API is made, but later when you try to work with the app ref data. But it's important to find out what API call it is, to find out what changed.

    Is it GetItem, GetItemBasic, GetItems or something else? As I already said, please tell me exactly what API call you make to get the data and the id of the app or item that you supply to the call.

    0
    Comment actions Permalink
  • Mark Broomfield

    Thanks for your response Casper. I know it's difficult for you to commit to time scales on the release of the new .NET client but when you say shortly do you mean within 6 months? Thanks Mark.

    0
    Comment actions Permalink
  • Casper Fabricius

    Mark, more like next week ;)

    0
    Comment actions Permalink
  • Amy Chung

    HI, any news on the new .NET client ?

    0
    Comment actions Permalink
  • Rudradev Pathak

    As of now simple fix to make it work is:

    Exception: Create Item Exception :Object of type 'Newtonsoft.Json.Linq.JArray' cannot be converted to type 'System.Collections.Generic.List`1[Podio.API.Model.FileAttachment]'.

    Description: Now Podio is processing files , But old Podio .net api is not having supported code.

    solution: Need to change below file code , as per instruction.

    class: Resthelper.cs

    method: private static object objectFromDict(object someObject, IDictionary<string, object> source)

    Replace (1) : if ( propertyMap.ContainsKey(item.Key))

    Replace above code (1) with below one.

    bool file = true;

    if (item.Key == "files")
    {
    file = false;
    }
    if (file && propertyMap.ContainsKey(item.Key))

    Note: Its worked for me.

    1
    Comment actions Permalink
  • Amy Chung

    Thank you ! It worked.

    0
    Comment actions Permalink
  • Shivakumar Krishnamurthy

    Thanks Rudradev. It does work! +1 from me

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk