Set "Password (2 Way Encrypted)" field using Table API http put

hz2
Tera Expert

Using ServiceNow HTTP Table API, is is possible to update credential fields? How can I encrypt the password? On the request body or can ServiceNow Encrypt?

 

For example: I need to update table "ldap_server_config" field "password". I've done the following:

PUT https://{instance_url}/api/now/table/ldap_server_config/{sys_id}
HEADER 
{auth header stuff}
BODY
{
  "passowrd": "123456"
}

 

This goes through with no issues, but the password is not encrypted. I know this by running the script below on the instance:

var gr = new GlideRecord('ldap_server_config');
gr.get('eecd75a30a0a0b2600791193785025b2');
gs.log(gr.getValue('password'));
// log output: *** Script: 123456
// field content has not been encrypted

What needs to be done to encrypt this password using http table api?

 

Why?

In my company, credentials are routinely rotated. When that happens, I have to launch ServiceNow and update the password manually. e.g. table ldap_server_config and update the "password" field. This is a manual step and prone to error. The ldap_server_config is just one example. There are several other credentials that I'd like to automate the password rotation.

 

I have written a PowerShell script that grabs latest credentials and updates ServiceNow tables using table API explained above. The problem is that the credentials are not encrypted and do not work as expected. 

 

Help please 🙂

1 ACCEPTED SOLUTION

hz2
Tera Expert

I've raised a hi ticket and got the answer. For future reference, this is that needs to be done:
"You need to add "sysparm_input_display_value=true" in the resource path"

An example:

PUT https://{instance_url}/api/now/table/ldap_server_config/{sys_id}?sysparm_input_display_value=true
HEADER 
{auth header stuff}
BODY
{
  "passowrd": "123456"
}

 

View solution in original post

1 REPLY 1

hz2
Tera Expert

I've raised a hi ticket and got the answer. For future reference, this is that needs to be done:
"You need to add "sysparm_input_display_value=true" in the resource path"

An example:

PUT https://{instance_url}/api/now/table/ldap_server_config/{sys_id}?sysparm_input_display_value=true
HEADER 
{auth header stuff}
BODY
{
  "passowrd": "123456"
}