Error parsing Json value in Rest API
Application Type
Service Studio Version
11.14.15 (Build 60242)

I'm consuming a Rest API and Outsystems is giving me an error when I call the action.

Failed to parse response of the method 'GetJobs' of the 'xxxxx' REST API:
Parsing '[2]._embedded.custom_fields[2].value': Error converting value 970404 to type 'System.Int64[]'. Path '[2]._embedded.custom_fields[2].value', line 1, position 34762.

When configuring the call Outsystems sets the structure field data type to "Long Integer List" .

I have tried changing it to "Integer List" but only to get :

Error converting value 970500 to type 'System.Int32[]'. 

I have tried changing it to "Text List" but only to get :

Error converting value 970368 to type 'System.String[]' 

(the values are different but they are all numbers)

The response (part that has the problem ) is like this:


              "id": 338775,

              "value": 970404,

              "_links": {

                "self": {

                  "href": "/jobs/15315075/custom_fields/338775"


                "definition": {

                  "href": "/jobs/custom_fields/338775"



Can anyone help me figuring how to fix this or what I am doing wrong?

Thanks in advance

Service Studio_001.png

Hi Ricardo,

long int should be fine, but it is not a list, it's a single value.  

So I would expect the data type of the value attribute in your structure to be Long Integer, not Long Integer List.

It is a bit of a mystery why OS configured it initially as a list, could this same API sometimes return a list instead of a single value ???


I think for this response, structure should be like this : 

Hi Dorine,

I have changed the data type to "Long Integer" but get another error:

Parsing '[0]._embedded.custom_fields[0].value': Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Nullable`1[System.Int64]' because the type requires a JSON primitive value (e.g. string, number, boolean, null) to deserialize correctly.
To fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '[0]._embedded.custom_fields[0].value', line 1, position 5088.

It is a list (apparently) but I haven't seen any "multiple values" being returned

Even if I use another rest call to provide only one "Job" that I know it only has one value in this field I get the 

 Error converting value 970404 to type 'System.Int64   Error


It's hard to help without example.  

Can you supply us with a demo oml containing the consumed api call and all the structures, and a (few) example responses from the api ?

For example, what is on line 1 at position 5088, can you show that ?

Hello Ricardo,

Can you please try to create response structure again by Testing your API and using copy to response body under API method. If response have same JSON structure every time it won't give error while assigning to structure created. If you still face issue their is good chance that you are getting different JSON body, in that case we have to format JSON text under OnAfterResponse method before assigning to structure.



Could there be something wrong with how outsystems receives the information ?

I have tested the response from outsystems in a Json validator and got many errors. 

After, I tested the same call from outside outsystems and the Json file presented no errors.

(beginning of) Response from Outsystems : 

"{""count"":18,""total"":18,""_links"":{""self"":{""href"":""\/jobs\/search?per_page=100&query=""}}, ......

(beginning of) Response from outside call : 

{"count":18,"total":18,"_links":{"self":{"href":"\/jobs\/search?page=0&per_page=100&query="}, ....

Is this normal ?


Hi Ricardo,

What you're seeing there is just the way Service Studio shows double quotes inside strings, it is totally normal and you can ignore it.

As for your problem, it might be that the REST service sometimes puts a single value in that item, and sometimes a list. There's misbehaving services like that out in the wild. What you should do is log the output of the REST service by increasing the logging level of the consumed service to "Full" in Service Center, then call the service, download the logging for the call, use a JSON pretifier to format the response, and check all instances of the "Value" attribute to see whether this is the case.

Hi Ricardo,

As Killian explained, Outsystems just wrap every elements in double quote and its fine. Now you can use some online JSON formatter and format your response to understand but there also you may need to remove extra quotes from response.

I still suggest you once try to re-create the structure with the response where you got the error and you can match with your earlier created structure, if it is same or not.

Basically the error is thrown while storing the JSON response into structure so this should be the place to check. If the response JSON string changes for different request, you will have to write some logic to manipulate JSON into OnAfterResponse method. We can help you here.



I don't think that works. Look at the errors he's getting. First, there this one:

Error converting value 970404 to type 'System.Int64[]'

This means there's an integer value in the JSON (970404), but the structure has an array (System.Int64[]). Then after converting the array in the Structure to a single value he gets this error:

Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Nullable`1[System.Int64]'

which is basicaly the opposite: it means there's an array ([1,2,3]) but the Structure has a single value (System.Int64).

And since both reference the same "value" attribute ([]._embedded.custom_fields[].value), this must mean that value can be both a single value and an array.

Hi Kilian, agree with you. There might be some issue with JSON response. And probably he will have to handle that in OnAfterResponse. But in meantime, if he tries to create a new structure with this JSON, he might be able to check if it is same as existing one and might possibly able to save at least this current response. Suggested as it is easy to start with this.

I have faced lots of this kind of error in my current project and had to handle those in OnAfterResponse method by manipulating JSON response, one of the reason behind this was change in response format. 


Yeah, handling in the OnAfterResponse is probably needed here. But let's wait to see whether Ricardo has managed to check the JSON he receives.


Sorry for the time I've taken...

I was trying to find why Outsystems had this behaviour with (only) this specific field and here is what I found.

Beeing a custom field for this application/platform (CatsOne) it can have (depending on the custom field configuration) one value or multiple values (hence the list). The particular value (custom field) I need only has one bur there are others (that I dint need) that can have multiple...

Can I in some way ignore the others ?


Well, at least I'm glad I was right about what the cause of the problems was :).

You cannot ignore it, unfortunately. The only thing I can think of is to add an OnAfterResponse and "fix" the JSON in there.

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