Passing special characters


If you are trying to pass special characters such as a backslash in your REST API script, you may encounter an error message like below. 

Response Body: {"errmsg":"Invalid json body.","status":1007}

This is very common scenario for wmi.user host property where \ is used for the domain account.


To fix this, you will need to add an escape character to the script. The rule of thumb is if you are using double quotes “” use \\\\ and if you are using single quote use \\. For example:

#Request Info
httpVerb ='POST'
resourcePath = '/device/devices/id/properties'
queryParams =''
data = '{"name":"wmi.user","value":"S007-AD05.corp\\\Admin"}'

This would add a wmi.user host property on the target device with value of “S007-AD05.corp\Admin”.