Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserializing attachment.List() fails (expects array, instead object returned) #140

Open
1 of 2 tasks
bluewalk opened this issue Jul 9, 2020 · 5 comments
Open
1 of 2 tasks

Comments

@bluewalk
Copy link

bluewalk commented Jul 9, 2020

Steps to reproduce:

  1. Query attachments, eg NoteAttachmentMasterCardAction

What should happen:

  1. 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:

  1. 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_03.<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
  • 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.

@bluewalk
Copy link
Author

Is there a way we can also generate the "Generated" models?

@bluewalk
Copy link
Author

bluewalk commented Aug 5, 2020

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.

@angelomelonas angelomelonas changed the title Deserializing attachmen.List() fails (expects array, instead object returned) Deserializing attachment.List() fails (expects array, instead object returned) Aug 13, 2020
@bluewalk
Copy link
Author

Unfortunately also not fixed in v1.14.1

@bluewalk
Copy link
Author

@angelomelonas Unfortunately still not resolved in v1.14.18

@bluewalk
Copy link
Author

bluewalk commented Jul 8, 2021

When will this issue be resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant