268
Views
3
Comments
Can't Deserialize JSON Response
Application Type
Mobile
Service Studio Version
11.53.25 (Build 61588)

Hey Guys,

I'm currently encountering the following error message from my POST response:

"Failed to parse response of the method 'POST' of the 'Ngrok' REST API: 

Parsing 'index': 

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'ssFunGhiWP.CcNgrok+RESTPOSTResponse[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path 'index', line 2, position 10."


We already tried to solve it by returning an array but it didn't help so it seems that something is not properly set up in OutSystems. 

The response in my REST looks like this:

{    "index": [        144    ],    "price": [        0.6    ],    "product_id": [        49    ],    "subcategory_id": [        10    ],    "supermarket_id": [        1    ]}

And the structure like this:

The HTTP trace for the Error Message is attached.  Appreciate any help! Thanks :)

Best,
Adriano

Ngrok.POST.trace.txt
2018-08-27 08-29-35
Fábio Vaz

Hi Adriano,

Please add the OnAfterResponse and set a debug on the assign, pick the response and create a new Struct from that JSON.

After that set the response type to your new struct and call it again.

UserImage.jpg
Adriano Villa Bascon

Hi Fábio,
thanks for your reply! That helped. The error was because the Response Output Parameter with the POST was set to be a List but the structure that came back wasn't. 

Thanks again! 

2018-08-27 08-29-35
Fábio Vaz

Good to know you have solved the problem ;)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.