REST API: DELETE /sys_user/{sys_id} returns 200 OK, but the record is not deleted

Dmitry Kosar
Mega Contributor

Hello!

I'm trying to delete user from sys_user table using DELETE HTTP method as described here documentation https://docs.servicenow.com/bundle/sandiego-application-development/page/integrate/inbound-rest/concept/c_TableAPI.html

According to documentation in case of successful removal API should return status code 204 OK

but I'm getting 200 OK response and the user record is not deleted. 

I've check ACL delete rules for sys_id table, it seems the rules are fine

find_real_file.png

find_real_file.png

Logs from Postman

DELETE /now/table/sys_user/0282... HTTP/1.1
Accept: application/json
Authorization: Bearer ...
User-Agent: PostmanRuntime/7.28.4
Host: <subdomain>.service-now.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Cookie: BIGipServerpool_...
 
HTTP/1.1 200 OK
Server-Timing: wall;dur=0, sem_wait;dur=0, sesh_wait;dur=0, app_cpu;dur=0, db;dur=1, acl;dur=0, br;dur=null, ui_action;dur=0, cache_build;dur=0, scripting;dur=0
X-Frame-Options: SAMEORIGIN
Content-Length: 0
Date: Fri, 13 May 2022 06:40:05 GMT
Server: ServiceNow
Strict-Transport-Security: max-age=63072000; includeSubDomains

Could you please help?

Am I missing something in ACL or Request is not correct?

 

Thanks!

1 ACCEPTED SOLUTION

Dmitry Kosar
Mega Contributor

My bad - URI was not correct. I've missed api/ part.

Thanks everyone!

View solution in original post

4 REPLIES 4

Aman Kumar S
Kilo Patron

Can you share the URI and request headers that are being passed on?

The user credentials that you are using to update, does it have admin or user_admin role, also you can't delete your own user as written in the advanced script in the ACL

Best Regards
Aman Kumar

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Dmitry,

Try deleting the user from REST API Explorer (System Web Services > REST > REST API Explorer).

I tried it and was able to delete and received a status code of "204 No Content".

find_real_file.png

REST API Explorer also shows the URL that was used. Can try entering this from a web browser next to check if the url would delete the user.

find_real_file.png

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Did you check the API user you are using has Delete Access or not on sys_user table?

Any before delete BR is blocking??

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Dmitry Kosar
Mega Contributor

My bad - URI was not correct. I've missed api/ part.

Thanks everyone!