JSON Serialize adding additional quotation

JSON Serialize adding additional quotation

  

Hello

i am attempting to use the json serialize to format a list. however the output returns as shown in the attached screen shot. this causes the request to fail as it sends the request as

"{\"age\":\"32\"}

how do i remove the additional backslash for this.

Note i tried using replace and it was not successful.

thanks

Hi Daniel,

Can you show me which structure you are serializing? Because the backslash is the escape character for the quotes (")

Kind regards,
Martijn Habraken

Martijn Habraken wrote:

Hi Daniel,

Can you show me which structure you are serializing? Because the backslash is the escape character for the quotes (")

Kind regards,
Martijn Habraken

Sure, its nothing too complicated, i created a simple structure as shown:

i then did an assign to update the age with a value and pass this through the serializer:

however i keep getting the below output:

i even tried creating an entity populated with some ages but the result seems to be the same:

see below for the output:

Note: when i check in service center, the error shows the backslash as well


thanks for your time

Hi Daniel,

The JSON looks correct for me. I didn't understand what are you trying to do with that JSON that gives the error you are describing.

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi Daniel,

The JSON looks correct for me. I didn't understand what are you trying to do with that JSON that gives the error you are describing.

Regards,

Marcelo


thank you for the reply


i am in the process of testing an application called UIPATH. the application allows the startting of jobs via API which i am attempting to trigger using the consume rest of Outsystems. for the particular API i am also trying to pass values through its "specific content" json attribute. i am able to do this via the API test in outsystems but when i assign as a server action i keep getting bad request with the error pointing to the specific content data. for reference, the format of the json for the API request is as shown below:

{
"itemData": {
"Priority": "High",
"DeferDate": "2018-03-21T13:42:27.654Z",
"DueDate": "2018-03-25T13:42:27.654Z",
"Name": "DocQueue",
"SpecificContent": {
"Email@odata.type": "#String",
"Email": "obrian@uipath.com", 
"Name@odata.type": "#String",
"Name": "O'Brian"
}
}
}

if i leave the specific content attribute out, the api responds fine, however i need to get the values in the specific content section formatted as above. i hope this helps 


daniel

Hi,

Since the API is a rest you define the inputs. You can define a structure with the correct format and say that input of the rest has the  type of that structure. 

Let me know how that goes.

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi,

Since the API is a rest you define the inputs. You can define a structure with the correct format and say that input of the rest has the  type of that structure. 

Let me know how that goes.

Regards,

Marcelo

hello

the problem seems to be with the escape characters that outsystems adds.mainly the \" in the json being sent to the rest api. is there any way to remove the escape sequence before the json is sent to the API. apologies if i am not explaining this properly.


daniel


Hi Daniel,

I create an example to explain better. As you can see to call this REST I created an input with the needed structure and as you can see the JSON sent is more less like the one you need. This should work as you want

If you still have some doubts provide what you have so far to see if I can create a working example for you.

Regards,

Marcelo

Solution

Marcelo Ferreira wrote:

Hi Daniel,

I create an example to explain better. As you can see to call this REST I created an input with the needed structure and as you can see the JSON sent is more less like the one you need. This should work as you want

If you still have some doubts provide what you have so far to see if I can create a working example for you.

Regards,

Marcelo

much appreciated,i will give it a try and let you know. thanks again


Solution

Daniel Singh wrote:

Marcelo Ferreira wrote:

Hi Daniel,

I create an example to explain better. As you can see to call this REST I created an input with the needed structure and as you can see the JSON sent is more less like the one you need. This should work as you want

If you still have some doubts provide what you have so far to see if I can create a working example for you.

Regards,

Marcelo

much appreciated,i will give it a try and let you know. thanks again


worked like a charm, thanks


Good to know :)