cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ian9
Community Member

How to delete a user completely?

Hi everyone! I created a user (student) using API. I want to delete it using API as well but I keep getting an error "The specified resource does not exist.".

Here's the API's I used:

API: POST /v1/accounts/{account_id}/users

const data = {
    "user[name]": name,
    "pseudonym[unique_id]": email,
    "pseudonym[sis_user_id]": email,
    "pseudonym[send_confirmation]": true
};

API: DELETE /v1/accounts/{account_id}/users/{user_id}

Error when calling DELETE API:
{
    "errors": [{
        "message": "The specified resource does not exist."
    }]
}

I'm doing this on the test environment. Please help!

Tags (2)
9 Replies
chofer
Community Coach
Community Coach

Hello again,  @ian9  Thank You for posting your question (you get two different badges from me...awesome!).  Again, I am not sure of an answer for you, but I'll also share this question with the Canvas Developers‌ group so that this question also gets some additional exposure.  As with the other question, you can follow and join this group if you would like.  I hope this will be of help to you.  Good luck!

pklove
Community Champion

What value are you using for user_id?   Is it the numerical Canvas id for the user?  Or are you using sis_user_id:sisid?

What do you have for account_id?

And do you have the /api at the beginning of your endpoint?

ian9
Community Member

What value are you using for user_id?   Is it the numerical Canvas id for the user?

Yes the id returned from user creation. I also use this id for enrollment which works.

Or are you using sis_user_id:sisid?

No

What do you have for account_id?

Same as the account_id I used for user creation.

And do you have the /api at the beginning of your endpoint?

Yes it does. I also tried it using the live API testing (Canvas Live API)  with same result.

James
Community Champion

Have your verified that the user account exists? GET /api/v1/users/{user_id}

It seems that at some point, I remember having trouble when trying to test using the same information over and over.

Are you using the root account? You said you're using the same account_id you used for the creation, but the deletion says it has to be done from the root account. If these aren't the same, it might be an issue. You can use the literal self instead of an id.

pklove
Community Champion

It should be working.

Before trying the delete, does the user appear in the results from:

   .../api/v1/accounts/1/users?search_term=user_id

chofer
Community Coach
Community Coach

Good evening,  @ian9 ...

I wanted to check in with you again because I noticed there hasn't been much activity in this topic since June 1, 2019.  While I don't have any additional information to share, I wanted to see if you've had a chance to review all the feedback that you've received form  @James  and pklove.  If so, do you feel that either of them have posted replies that have helped to answer your question?  Please feel free to click on the "Mark Correct" button next to one of their responses if you feel that it has helped to answer your question.  But, if you're still looking for some help, please post a note below letting us know how we might be able to help.  For the time being, I am going to mark your question as "Assumed Answered" ... mainly because there hasn't been any new activity in this topic for six months.  However, that won't prevent you or others from posting additional questions and/or comments below that are related to this topic.  I hope that's okay with you, Ian.  Looking forward to hearing back from you soon.

julian_ebeli
Community Participant

I can't see an option in the users api for delete.

https://canvas.instructure.com/doc/api/users.html

Using the API you can delete a user login and a user enrolment but not the user itself.

Correct me if I'm wrong about this?

You can delete a user via the Canvas interface (in user details)

pklove
Community Champion

Deletion is done at the account level, see the first post in this thread, or: Accounts - Canvas LMS REST API Documentation 

julian_ebeli
Community Participant

Thanks Peter, you are right.

Why didn't I think to look in the 'Accounts' section of the documentation?!

You'd think there could at least be a link to it in the Users API docs, to my mind that's were the function belongs, even though I also know users are a root account property.

We live and learn.

Cheers