Unnecessary backslash while making a REST-call

0
I'm trying to send an array of values in a string. Each value is between double quotes and the values are separated by a comma.  the REST-call works well when I try to send one value, unfortunately when I send an array the REST-call creates extra slashes in front of the double quotes. For example: When I send 41aedf3e-a53e-4d2b-8940-4293b0127ec6 the endpoint receives {"added":["41aedf3e-a53e-4d2b-8940-4293b0127ec6"]}   When I send 41aedf3e-a53e-4d2b-8940-4293b0127ec6","4055fc06-0d19-40e3-92c6-60f4ac517ffa the end point receives :{"added":["41aedf3e-a53e-4d2b-8940-4293b0127ec6\",\"4055fc06-0d19-40e3-92c6-60f4ac517ffa"]}  As you can see the extra backslashes were created. Does anyone know a solution for this?
asked
2 answers
2

Hi Willem,

You are trying to insert a list of values into one data field and that's not the way Mendix wants it. Your string will be treated as data and therefore quotes are escaped. If you insert your structure into a JSON snippet, you will see Mendix needs a List of "wrappers":

 

You can use a JSON-snippet like this and then create an Export mapping based on this JSON to fill it correctly:

 

And then use this as export mapping in your REST POST action:

 

answered
0

What Mendix-version are you using?

Seems like the " gets escaped by adding the \, although it should not get escaped. You're example does not start with " which makes me expect you have a parsing step that is responsible for adding the \. The parsing step escapes the " because it is busy parsing a string, not an array. Check if your JSONstructure and Export mapping in line with the data you are trying to send.

 

 

answered