ServiceNow REST API - issue in /table API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 07:22 AM
Hi, community,
When I am trying to clear the first_name, last_name & middle_name of a user from the sys_user table using REST API. It's only removing the middle_name but not first_name & last_name. Please find the below CURL command
curl --location --request PUT 'https://dev<ID>.service-now.com/api/now/table/sys_user/<SYS_ID>' \
--header 'Authorization: Basic <REPLACE_ME>' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "",
"last_name": "",
"middle_name": ""
}'
Please help me to understand this behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 07:36 AM
It is possible that the issue with clearing the first_name and last_name fields is due to the ACL (Access Control List) permissions set up for the sys_user table.
To clear the first_name, last_name and middle_name fields of a user from the sys_user table using REST API, you can try the following steps:
- Check if the current user has the necessary permissions to update the sys_user table. You can do this by verifying that the user has the appropriate role(s) or ACL(s) that allow them to update the sys_user table.
- If the user has the necessary permissions, modify the curl command as follows:
curl --location --request PUT '<https://dev><ID>.service-now.com/api/now/table/sys_user/<SYS_ID>' \\ --header 'Authorization: Basic <REPLACE_ME>' \\ --header 'Content-Type: application/json' \\ --data '{ "first_name": {"value": ""}, "last_name": {"value": ""}, "middle_name": {"value": ""} }'
This modification includes using a JSON object with a value property for each field instead of just an empty string. This can help bypass any ACL restrictions that may prevent the fields from being cleared.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 02:09 AM
Hi @DUGGI ,
The user I am using to authenticate the above REST call is an 'admin' user. So, permissions is not an issue. I have also checked the ACL.
I have tried with this input body
{ "first_name": {"value": ""}, "last_name": {"value": ""}, "middle_name": {"value": ""} }
But I got the below response