bunq / sdk_csharp

C# SDK for bunq API
MIT License
35 stars 22 forks source link

ArgumentException in SessionServerConverter #7

Closed BabyDino closed 7 years ago

BabyDino commented 7 years ago

I'm fairly new to C# so please be gentle with me ;) I am creating an UWP app. I run into an exception in SessionServerConverter:29:

var jObjects = JArray.Load(reader).ToObject<List<JObject>>();

My code (IP masked):

IList<string> permittedIps = new List<string>();
permittedIps.Add("x.x.x.x");

var apiContext = ApiContext.Create(ApiEnvironmentType.SANDBOX, API_KEY, DEVICE_DESCRIPTION, permittedIps);
apiContext.Save("Config/bunq.conf");

Stacktrace:

  HResult=0x80070057
  Message=Arg_WrongType, [], Newtonsoft.Json.Linq.JObject
  Source=<unknown>
  StackTrace:
   at System.Collections.Generic.List`1.System.Collections.IList.Add(Object item) in f:\dd\ndp\fxcore\src\System.Collections\System\Collections\Generic\List.cs:line 254
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   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.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   at Bunq.Sdk.Json.SessionServerConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in C:\Users\BabyDino\Documents\GitHub\sdk_csharp\BunqSdk\Json\SessionServerConverter.cs:line 29
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)

bunq responses are OK (checked with profiler). The device will register without issue. Tried earlier versions of Newtonsoft.JSON as well. Seems to be a casting issue?

dnl-blkv commented 7 years ago

@BabyDino you're very right, it is a bug on our side. I have got a fix and will release it shortly. Thanks for reporting!

@OGKevin Let's make it a patch. Please tag as 0.9.2.

OGKevin commented 7 years ago

@BabyDino FYI

dnl-blkv commented 7 years ago

@BabyDino Please check https://www.nuget.org/packages/Bunq.Sdk/0.9.2-beta

Feel free to poke us if it breaks somewhere :)

BabyDino commented 7 years ago

Ahwww yessss!