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

geomathew
Giga Contributor

Can u pls give some clarity on how you are setting the value....


I try to send it as '70,80' .


Can you please let em know on how to set/get the value?


Try below...I tested and its works for me.



var str = '1,2,3,4,5';


gs.print(global.JSON.stringify(str.split(',')));


I get the status code as 400 and it did not pass through. Should I change the JSON message?