REST API Post - JSON content type

vinitha3
Tera Guru

Hello,

This is a part of my JSON message which accepts array input

{

"value": {"array": { "elements": [

{"number": {"value": 80}},

{"number": { "value": 100 }}

]}

},

"type": "Array/number",

"name": "cdmAddDisk",

"scope": "local"

}

The value I have to pass here comes from a Request Item multi line text separated by commas.

But it does not accept it. Any idea?

Thanks,

Vinitha.K

1 ACCEPTED SOLUTION

vinitha3
Tera Guru

I got it by setting r.setStringParameterNoEscape();



r.setStringParameterNoEscape("cdmAddDisk",global.JSON.stringify(str.split(',')).replace(']',',]').replace(/\"/g,"{\"number\": {\"value\":").replace(/{\"number\": {\"value\":,/g,"}},").replace(',]',']'));



Thank you so much for the help.


View solution in original post

14 REPLIES 14

Can you let me know how to get the JSON message from this script?



Thank You,



Vinithabanu Kaliamurthi| Senior Application Software Developer | CDM Smith | Tel: (617) 452-7705 | e-mail: vinithabanuk@cdmsmith.com<mailto:vinithabanuk@cdmsmith.com>


Pls share your REST POST content defined in you outbound REST configuration...


{"parameters":


[



{


"value": {"array": { "elements": [


{"number": {"value": 80}},


{"number": { "value": 100 }}


]}


},


"type": "Array/number",


"name": "cdmAddDisk",


"scope": "local"


}


,


{


"value": {"string":{ "value": "4:00AM"}},


"type": "string",


"name": "cdmPowerStartTime",


"scope": "local"


}


,


{


"value": {"string":{ "value": "6:00PM"}},


"type": "string",


"name": "cdmPowerStopTime",


"scope": "local"


}


,


{


"value": {"string":{ "value": "No"}},


"type": "string",


"name": "cdmPowerWeekends",


"scope": "local"


}



]}


vinitha3
Tera Guru

I got it by setting r.setStringParameterNoEscape();



r.setStringParameterNoEscape("cdmAddDisk",global.JSON.stringify(str.split(',')).replace(']',',]').replace(/\"/g,"{\"number\": {\"value\":").replace(/{\"number\": {\"value\":,/g,"}},").replace(',]',']'));



Thank you so much for the help.


Good   - Pls mark this as answered so that it will help others also...