Get a 405 trying to delete a user using the API
See original GitHub issueDescribe the bug
The command to delete a user does not seem to be working.
To Reproduce
I followed the example in https://github.com/keycloak/keycloak-nodejs-admin-client/blob/master/test/users.spec.ts
let user = await kcAdminClient.users.findOne({email})
// Confirmed this is working and `user` is what I expect
await kcAdminClient.users.del({
id: user.id,
});
I expect it to quietly delete the user. Instead I get an exception thrown:
status: 405,
statusText: 'Method Not Allowed',
...
data: {
error: 'RESTEASY003650: No resource method found for DELETE, return 405 with Allow header'
}
I’ve logged into the admin console, found the user and deleted them there and it works; so I think the eliminates any firewalls or server settings.
In the browser network tab I can see a DELETE request was sent, and the headers look to match what I see in the nodejs exception. One difference is that the exception doesn’t show the user ID in the URL (so I assume it is in body data?).
Enviroment (please complete the following information):
- OS: Ubuntu
- Keycloak Version: 15.0.1
- NodeJS 16.4.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
WebAPI Delete not working - 405 Method Not Allowed
This issue is mainly related to WebDAV extension module on IIS server. this happened while Using Post OR delete action. Please try below...
Read more >Delete User : 405 method not Allowed - HubSpot Community
Hi. I'm using API for insert / update my users list (batch) with my hapikey. But I've an error when I want to...
Read more >Getting Error 405 on Delete REST API when running Azure ...
The Post APIs works. So, I can do a POST (to create a user) but when I do a Delete (to delete that...
Read more >DELETE User response: 405 Method Not Allowed
EDIT: To be very clear the error is the response 405 “Method Not Allowed” I've checked the app permissions and roles, all seem...
Read more >405 error when trying to delete environment from REST API
I'm trying to delete an Environment using the REST API (through PowerShell Invoke-RESTMethod) but receiving “error 405 method not allowed”.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @armujahid: that turned out to be the problem for me too. (I was just forced to revisit this!)
I think the underlying problem comes down to the surprising behaviour of
findOne()
described here: https://github.com/keycloak/keycloak-nodejs-admin-client/issues/461#issuecomment-1106365661I.e. if you search on
id
as shown in the spec.ts document, it returns a user object, and if you search on anything else, such as email, it returns an array of user objects.This just needs to be documented clearly somewhere. Perhaps also add a second unit test showing a delete by a field other than
id
; this is behaviour that needs testing. A simple clone of thatuser.del
unit test, and swappingid
foremail
should do it?Feel free to open up a PR for adding another test, that’s always appreciated!