Delete Deactivated User

Hi,
I’m looking to delete the deactivated user.

I had deactivated the user by

User user = client.getUser(id);
user.deactivate();

then if i try to delete them in another method
User user = client.getUser(id);
user.delete();

this is not working when we are giving in different methods.It gives error like
“Resource not found” but the user is still in OKTA

But when we are giving in same method it is working fine.

like
User user = client.getUser(id);
user.deactivate();
user.delete();

But i need to give in different methods for deactivate and delete.Could you please give some idea to solve this issue.

Thanks!

I guess, the id here means user shortname/login? If so, then getUser will report that the user is not found, if it’s deactivated (that what’s happening when you try to delete in a different method). You can delete user by guid, if you save it somewhere.

Try to search for the user, after you deactivated it, instead of getUser. Sorry, not sure which language/SDK you use