Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Password Set while creating user through API Rest Payload

saurabhchhajed
Kilo Explorer

Hi,
I am using rest API to create user on Service Now
and my payload

{"user_name":"Watson",

"first_name":"John",

"last_name":"Watson",

"email":"watson@bcone.com",

"city":"Pune",

"department":"IT",

  "user_password":"pass,123"

}

when i run this it create the user on service now but it set the user_password as "pass,123" not as encrypted form so when i try to login with that password it says wrong password.
But when i fetch the different existing user from service now it shows me the password in encrypted form ie.

"user_password": "$s$AJFl3zx3LV/bClnko1qSKXDoavxl4zAHGqq5FzmJdQw=$2zgOx5fqrBM2t7uLJwKhO9Vi3hZkKNCF+M6o26Thh3I="
so i want to know how i encrypt my password and send it through payload or is there any other way to Set the user password.

2 REPLIES 2

john_roberts
Mega Guru

If you wanted to set the incoming string as the actual password (pre-encrypted), you can use the REST parameter, sysparm_input_display_value=true. This will set "pass,123" as the password and encrypt the value in the database. The same way as GlideRecord.setDisplayValue("user_password","pass,123").


Just be aware that all inbound field values will be considered display values as well.


Table API - ServiceNow Wiki


You're the best.   This worked like a charm.