sdk_csharp
sdk_csharp copied to clipboard
Deserializing attachment.List() fails (expects array, instead object returned)
Steps to reproduce:
- Query attachments, eg NoteAttachmentMasterCardAction
What should happen:
- Deserialize Attachment property to an AttachmentMonetaryAccountPayment as the swagger info states at e.g. https://doc.bunq.com/#/note-attachment/List_all_NoteAttachment_for_User_MonetaryAccount_RequestInquiryBatch
What happens:
- Throws exception like
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Bunq.Sdk.Model.Generated.Object.AttachmentMonetaryAccountPayment]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
Traceback
Path 'attachment.id', line 25, position 9. 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.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) 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.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) at Bunq.Sdk.Json.BunqJsonConvert.DeserializeObject[T](String value) in C:\Temp\Projects\sdk_csharp\BunqSdk\Json\BunqJsonConvert.cs:line 51 at System.Linq.Utilities.<>c__DisplayClass2_0
3.<CombineSelectors>b__0(TSource x) at System.Linq.Enumerable.SelectIListIterator2.ToList() at Bunq.Sdk.Model.Core.BunqModel.FromJsonList[T](BunqResponseRaw responseRaw, String wrapper) in C:\Temp\Projects\sdk_csharp\BunqSdk\Model\Core\BunqModel.cs:line 110 at Bunq.Sdk.Model.Generated.Endpoint.NoteAttachmentMasterCardAction.List(Int32 mastercardActionId, Nullable1 monetaryAccountId, IDictionary2 urlParams, IDictionary`2 customHeaders) in C:\Temp\Projects\sdk_csharp\BunqSdk\Model\Generated\Endpoint\NoteAttachmentMasterCardAction.cs:line 173
SDK version and environment
- Tested on 1.13.0
- [ ] Sandbox
- [x] Production
Extra info:
NoteAttachmentMasterCardAction.cs and others define the attachment property as
public List<AttachmentMonetaryAccountPayment> Attachment { get; set; }
In fact the json returns an object. Changing these properties to a simle
public AttachmentMonetaryAccountPayment Attachment { get; set; }
fixes the issue.
This applies too all NoteAttachmentXXX classes.
Is there a way we can also generate the "Generated" models?
Unfortunately v1.14.0 doesn't fix this...
https://github.com/bunq/sdk_csharp/blob/develop/BunqSdk/Model/Generated/Endpoint/NoteAttachmentMasterCardAction.cs#L86
Seems like the swagger also states it should be a collection, but the API returns an object.
Unfortunately also not fixed in v1.14.1
@angelomelonas Unfortunately still not resolved in v1.14.18
When will this issue be resolved?