API Question deleting teachers and students with classes

lehmanp00
Contributor III

We have scripted deleting teachers using the API by first pulling information from the /users/id call. This can give us the computer and ipad the teacher has assigned. We get the id's of the devices from that GET call. We use DELETE in /computers/id and /mobiledevices/id to flush out the location attributes to remove the the teacher and we can then delete the teacher without issue.

However if a teacher is in a class(es), we don't get the roster list in the /user/id call. If I do a DELETE on the teacher with classes, JSS does bring back information on the classes that the teacher is associated with. I was wondering if there was a better way to get back the class information than having to do a initial DELETE in the API to get the class list. Or do I have to traverse the entire classes list and look for the teacher? Or is there any other method to remove a teacher from classes easily through the API?

Thanks for any help.

1 REPLY 1

brad
Contributor

Hi @lehmanp00 ,

I am not sure there is a great way to get what class a teacher is associated without getting all of the classes with the API. If the class was listed in the API response, you could parse the response and have it go out and remove the staff member from that class and then try the delete again.

I am wondering why you are deleting teachers from the JSS, is it because they have left? Do your classes sync with your SIS? If so, can you delete the teacher there first, then delete them from the JSS after the classes have synced?

I hope that helps.

Brad