creating a sys_user using rest api call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2023 03:17 PM - edited ‎04-11-2023 04:03 PM
I want to create a new login user using rest API.
I can post to sys_user table right?
I see that sys_user table has a role field. How can I assign multiple roles while creating the user. I tried to put a comma separated list as a value for the role field. e.g
{"first_name":"xx","last_name":"yy","company":"Aa","roles":"admin,user","user_name":"superuser"}
The response shows success but in the actual user record I don't see any roles assigned.
So how do I assign roles thr' rest API
I also want add user to a group.
Do I need to write a separate rest call to sys_user_group to create a group?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 01:03 PM
Without using import/transform you are limited to adding a single record\relationship per payload and will need to use the sys_id of the role, not the name of the role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 10:57 PM
Thanks @Tony Chatfield1
I think I am able to assign admin role to the user I am creating. But I still can not login using this newly created user. I get error as username or password invalid. Also when I try to make any other rest API call using the username/password I newly created, I get 401 error.
So I think password is not getting set for this user. Can I see password field in the user record in servicenow UI to check if it is correct ?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 11:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 11:49 PM
The password field is 1 way encrypted and so you cannot see if it is correct, but you can test the account by trying to login using a different browser or an incognito\private window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 04:07 AM
I think I may need to crate a role record using sys_user_role? But I can access that table from rest api explorer?
How do I enable sys_user_role?
Thank you