ngocnicholas / airtable.net

Airtable .NET API Client
MIT License
138 stars 34 forks source link

Cannot Deserialize Array Field Values in Records #77

Closed thomas-gandy closed 9 months ago

thomas-gandy commented 1 year ago

Given a field KeyValuePair {[fldQBmD4P1IuYiBVI, ValueKind = Array : "["recQtNiswAnjzGJHO"]"]}, attempting to deserialize it with record.GetField<List<string>>("fldQBmD4P1IuYiBVI") throws the following exception

'record.GetField<List<string>>("fldQBmD4P1IuYiBVI")' threw an exception of type 'System.NotSupportedException'
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233067
    HelpLink: null
    InnerException: null
    Message: "The only generic type supported is Nullable<T>"
    Source: "AirtableApiClient"
    StackTrace: "   at AirtableApiClient.AirtableRecord.ParsePrimitiveValue(JsonElement element, Type type)\r\n   at AirtableApiClient.AirtableRecord.GetField[T](String fieldName)"
    TargetSite: {System.Object ParsePrimitiveValue(System.Text.Json.JsonElement, System.Type)}

However, deserialization with atomic types works as expected.

Currently, as there does not seem to be support for returning records with field keys as field IDs (only names), I have made a direct call to the Airtable Web API and have then read that JSON response into an AirtableRecord instance. This AirtableRecord instance is what is being used in the above example and is why the field key is not the human readable column name.

ngocnicholas commented 1 year ago

Support for returning records with field keys as field ID will be in the next release coming out soon.

ngocnicholas commented 9 months ago

Fixed in 1.4.0