How to escape double quotes(") in rest endpoint url for OutBound rest message? %22 is not working.

Akshatha Ballal
Tera Expert

Hi,

I use " in my rest end point url for a get query to Nlyte and I am unable to escape it using %22. Please refer the url below and let me know where I'm doing it wrong.

http://IP-Address/nlyte/integration/api/odata/AssetsAndHosts?$filter=((SerialNumber%20ne%20%22%22)&(SerialNumber%20ne%20null))&$select=AssetName,AssetNumber,

What I want to achieve is (SerialNukber ne "" & SerialNumber ne null)

Using %20 (SerialNumber%20ne%20null) for space encoding is working fine

http://IP-Address/nlyte/integration/api/odata/AssetsAndHosts?$filter=((SerialNumber%20ne%20%22%22)&(SerialNumber%20ne%20null))&$select=AssetName,AssetNumber,SerialNumber

Error message:

{

  "error":{

    "code":"","message":"The request is invalid.","innererror":{

      "message":"An error has occurred, please verify parameter values and try again.For detailed information please contact system administrator or check server logs.\nInternal Error Message: Syntax error: character '\"' is not valid at position 18 in '((SerialNumber ne \"\")'.","type":"","stacktrace":""

    }

  }

}

 

Regards,

Akshatha

12 REPLIES 12

MrMuhammad
Giga Sage

Hi Akshatha,

Have you tried using backslash (\) with double quotes(")? Something like this (\").

Regards,

Muhammad

Regards,
Muhammad

It did not work, it says invalid URI

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

You can use variable substitution for that and then use setStringParameterNoEscape()

Variable substitution in outbound REST messages

https://community.servicenow.com/community?id=community_question&sys_id=db141598db12e3401089e15b8a96...

setStringParameter() vs setStringParameterNoEscape()

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Can you explain this in detail? How exactly am I supposed to make use of this in the code? 

(SerialNumber%20ne%20$input) --> Is this the url in the rest endpoint?

sm.setStringParameterNoEscape("input","""");  --> Is this the way to use it where we call this rest message?

 

A little more detailed explanation would be really helpful.