can not login using credentials I created thr' rest API

Deepali5
Tera Contributor

I created a user using rest api posting to sys_user

I gave username and password

payload = {"first_name": "Dummy",
"last_name": "User",
"user_name": "user1",
"user_password": "<Somepassword>"
}
I got success response 201
I also assigned admin role to this user.
I can see this user record being created in servicenow.
but if I logout from admin and try to login into servicenow as this new user1, using the credentials I created, I
get error as username or password is incorrect
 
I am trying do a third party integration with servicenow, for that I need to create my own user and the integrate into incidents.
I want to automate the whole process including creating user. I am just testing right now with rest explorer.
Will look into creating imports/transform later.
 
How do I know if password is set correctly? If not how to set the password thr' post rest API call?
 
Thank you
1 ACCEPTED SOLUTION

Prince Arora
Tera Sage
Tera Sage

@Deepali5 ,

 

I have tried this in my PDI and worked really well for me!

 

Could you please try this, I have used the same body which you mentioned 

 

You are going in the right direction, can you make "sysparm_input_display_value" to true as mentioned in the screenshot.

 

PrinceArora_0-1681365852220.png

 

PrinceArora_1-1681365918867.png

 

After creation of user, I was able to login with the user_name and password!

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

 

 

 

View solution in original post

10 REPLIES 10

Ian Mildon
Tera Guru

As your normal Admin login, check the sys_user record to see if "web services access only" is checked. If it is, the account can login via the API connection but will not be able to perform a local login

@Ian Mildon 

web services access only" is not checked and I am neither able to login from my app nor perform a local login.

When I try to post from rest API connection thr' my app using this user I get 401 error.

So may be password is not getting set. Can I see if the password is set thr' rest API in the sys_user record?

Thank you for your help..

Weird
Mega Sage

Check the XML of the user record and see if the password field is properly showing an encrypted password or just the plain text you used.

Prince Arora
Tera Sage
Tera Sage

@Deepali5 ,

 

I have tried this in my PDI and worked really well for me!

 

Could you please try this, I have used the same body which you mentioned 

 

You are going in the right direction, can you make "sysparm_input_display_value" to true as mentioned in the screenshot.

 

PrinceArora_0-1681365852220.png

 

PrinceArora_1-1681365918867.png

 

After creation of user, I was able to login with the user_name and password!

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.