ServiceNow REST API - issue in /table API

Dhiman
Tera Contributor

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.

2 REPLIES 2

DUGGI
Giga Guru

@Dhiman 

 

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:

  1. 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.
  2. 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.

Dhiman
Tera Contributor

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

{
"result": {
"last_name": "{value=}",
"middle_name": "{value=}",
"first_name": "{value=}"
}
}