podio

.net API throwing exception "JSON integer is too large or small for an Int32. Path 'item_id', line 1, position 1486"


I'm using the .net client library, v1.5.9 which is the latest version, and am receiving the following error when attempting to add a new item on the ItemService:

Newtonsoft.Json.JsonReaderException: JSON integer 2151368024 is too large or small for an Int32. Path 'item_id', line 1, position 1486.
   at Newtonsoft.Json.JsonTextReader.ParseReadNumber(ReadType readType, Char firstChar, Int32 initialPosition)
   at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadNumberValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsInt32()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonConverter[] converters)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonConverter[] converters)
   at PodioAPI.Utils.JSONSerializer.Deserilaize[T](String json)
   at PodioAPI.Podio.Request[T](RequestMethod requestMethod, String url, Object requestData, Object options)
   at PodioAPI.Podio.Post[T](String url, Object requestData, Object options)
   at PodioAPI.Services.ItemService.AddNewItem(Int32 appId, Item item, Nullable`1 spaceId, Boolean silent, Boolean hook)

This is because the ItemId property is an int instead of long.

The client library hasn't been updated in years and it's been marked as archived now so I can't PR a fix.

Is there a way around this issue or do I have to replace the client library in my code with my own implementation?


Solution

  • I fixed this issue by downloading the source code of the library, add the local reference and change the data type from int to long.

    https://github.com/podio/podio-dotnet

    But it seems there is only asynchronous version available (even the Podio .NET project is async), you may need to change the way you call the functions a bit.