Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Delete user with proget api
-
Hello,
I'm using the ProGet api endpoint DELETE /api/security/users/delete?user=«username» to delete a user. Although the request return a 200 OK response, the user is not removed and still appears in ProGet. -
My guess is there's some kind of typo with the username you're sending.
The name is not validated before attempting to delete, which means you can type in any string and a
200will be returned.If you don't send an arggument, you will get an error however.
I would also try using
pgutil security users deleteto see if that helps:
https://docs.inedo.com/docs/proget/api/security/users/deleteThanks,
Alana -
@atripp
Thanks for your quick answer.
I checked the name and it's correct, I was able to find it into the proget portal.
I also check the Diagnostics Center but not error appear.
Do I need to add simple or double quote around the name?
Does pgutil a better option the api? -
Maybe you're attempting to delete a principal that's not a user, such as a group or
Anonymousor something.In any case, the API uses the exact same code as the UI; I'll share it:
case "delete": EnsureMethod(context, "POST", "DELETE"); var userName = context.Request.QueryString["user"]; if (string.IsNullOrEmpty(userName)) throw new HttpException(400, "Expected user query argument."); DB.Users_DeleteUser(userName); break;Here is the UI code for the button click on the
/administration/security/users/delete-user?userName=asdfasdfpage:var btnDelete = new PostBackButtonLink( "Yes, Delete User", () => { DB.Users_DeleteUser(this.UserName); WebUserContext.ClearCache(); this.CloseModalWindow(false); } );Your request might not be reaching the endpoint; I would attempt to do
DELETE /api/security/users/delete?something=nothingto make sure you're getting a400error.Hope that helps.
Alana -
Hello,
Following your idea, I have done a test with wrong api call to remove a user from a group and I got an error into Proget Diagnostic Center. This stage confirm that I reach the correct server. I remove the error and the server answer me 200 but the user is still there.
I'm using Proget version 2025.26 (Build 11).
The apikey to do such operation is the admin one.
The url xxx/api/security/groups/update
The body of my request was{ "users": [ "username" ], "name": "group" }The server answer is
VERBOSE: WebRequest: v1.1 POST https://mydomain/api/security/groups/update with application/x-www-form-urlencoded payload with body size 109 B (109 bytes)
VERBOSE: WebResponse: 200 OK with body size 0 b (0 bytes).
How can I trust a server which is not able to accomplish a task.
I can do it manually and with pgutil. -
The API is a bit harder to use than just
pgutil, so I'd suggest to usepgutilinstead and it's easy to make a simple mistake like encoding something incorrectly. Without studying your code and having direct access to your ProGet instance, I cannot tell you what the issue is.But, since
pgutilworks we know the API is fine; here is the code thatpgutiluses to delete the user:
https://github.com/Inedo/pgutil/blob/thousand/Inedo.ProGet/ProGetClient.cs#L744would suggest to use a local proxy tool like fiddler classic, proxyamn, postman, etc., that can capture and analyze local HTTP traffic so you can see the difference between what your code is doing and what
pgutilis doing.Thanks,
Alana
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login