HI need quick help with Rest API

pragadez
Tera Contributor

Im using Rest Step to invoke API to an 3rd party IT Desk

pragadez_0-1740076599005.png

 

However the description with special character are not constructed properly for the input json.


Description in service now is this  > Path :\\100.0.0.1\homedir\homedir\Network\Management

The whole input data sent which is not recognized

[{"name":"input_data","type":"application/json","order":0,"value":"{\"change\":{\"title\":\"A failed RAID controller card needs to be replaced on PSORA1\",\"description\":\"Path :\\\\100.0.0.1\\homedir\\homedir\\Network\\Management\"}}","itemType":"multi-part-data","part_type":"text","content_type":"application/json","set_content_type":"from_attachment","file_name":"","set_file_name":"from_attachment","showType":true,"label":"input_data"}]

when i send this directly the input is not recognized as JSONInput in the 3rd party IT Desk.

 

So i stringified the description to add escape sequence with a Script Step before executing the Rest API . However not encountering error in Service now itself. Receiving this error Error encountered executing HTTP request

[{"name":"input_data","type":"application/json","order":0,"value":"{\"change\":{\"title\":\"A failed RAID controller card needs to be replaced on PSORA1\",\"description\":"Path :\\\\\\\\100.0.0.1\\\\homedir\\\\homedir\\\\Network\\\\Management"}}","itemType":"multi-part-data","part_type":"text","content_type":"application/json","set_content_type":"from_attachment","file_name":"","set_file_name":"from_attachment","showType":true,"label":"input_data"}]

Looks like the json for the input is not well construced.

Need quick assistance in this

Thanks in Advance

 




3 REPLIES 3

JenniferRah
Mega Sage

Can you change your Input Data type to JSON? It looks like it is trying to make it into a text string, which makes it put the quotes around it and escape the internal quotes.

Hi Thanks for the reply,

 

pragadez_0-1740152330355.png

I have only two options list and also the content type is set to application/json only. Refer below image.

pragadez_1-1740152380722.png

 

I could be wrong please guide me if anything can be done


Thanks in Advamce

Change the request type from MultiPart to Text. Then either compile the payload in a Script step before the API call and insert it into the body like this or put the payload in the way you have it. 

 

JenniferRah_0-1740168466829.png