Jai_Spicer | 2021-03-07 23:16:05 UTC | #1
Does anyone know if this has been implemented yet? I am attempting to search for previously 'deleted' users to reactivate them.
https://developer.mypurecloud.com/forum/t/how-do-you-get-inactive-users/896
Jerome.Saint-Marc | 2021-03-08 08:02:39 UTC | #2
Hello,
The /api/v2/users endpoint allows to list active, inactive and deleted users. See the "state" query parameter of this endpoint (default value: active - valid values: active, inactive, deleted, any).
You can also explore what you can do with this endpoint using the Developer Tools - API Explorer. See this other post on the Community forum: https://community.genesys.com/digestviewer29/viewthread?GroupId=19&MessageKey=be4e448f-1ea0-4e23-b72b-d81351fb1e11&CommunityKey=bab95e9c-6bbe-4a13-8ade-8ec0faf733d4&tab=digestviewer&ReturnUrl=%2fcommunities%2fcommunity-home1%2fdigestviewer%3fCommunityKey%3dbab95e9c-6bbe-4a13-8ade-8ec0faf733d4
Regards,
Jai_Spicer | 2021-03-08 21:22:12 UTC | #3
correct me if I'm wrong but this only works if you have the ID of the user. I only have the email address of the user.
tim.smith | 2021-03-08 21:34:16 UTC | #4
GET /api/v2/users/{userId} does require a user ID. GET /api/v2/users does not. The link above has usage details for this resource.
Jai_Spicer | 2021-03-08 22:31:50 UTC | #5
Looking at the api explorer there is no clear way to be able to do any sort of filtering or search for an email address using this endpoint.
Jai_Spicer | 2021-03-09 00:49:59 UTC | #6
Looks like it is possible to do it with the /api/v2/users/search endpoint
{ "returnFields": [ "id", "name", "email" ], "query": [ { "value": "person@email.com", "fields": [ "email" ], "type": "EXACT" }, { "values": [ "inactive", "active" ], "fields": [ "state" ], "type": "EXACT" } ] }
John_Carnell | 2021-03-09 14:10:23 UTC | #7
Hi Jai,
You can do this with a search, but it also possible to do this with the GET /api/v2/users?state=inactive. In API explorer this is the last field on the screen. Also, if you are just trying to get a list of all the inactive users you can use our CLI and JQ to produce a list of users:
gc users list -a --pageSize=100 --state=inactive
Thanks, John Carnell Manager, Developer Engagement
Jai_Spicer | 2021-03-09 21:07:56 UTC | #8
If I used the GET /api/v2/users?state=inactive endpoint this would return all inactive users in my environment. When I'm only looking to see if a user with certain email address is inactive or active.
John_Carnell | 2021-03-10 13:11:00 UTC | #9
Hi Jai,
Ok. Now I understand. Yes, the search API is appropriate here if you want to write a script around this. Another option would be to use our CLI and JQ to dump all the users and then filter the returned list by email address. If looking up these users is something you do as an administrative task you could do something like this:
`gc users list -a --pageSize=100 | jq -rc 'first(.[] | select(.email == "john.carnell@genesys.com"))' | jq '`
I have even taken commands like this and wrapped them in 4-5 line python scripts and then put them as aliases in my shell for quick access.
Thanks, John Carnell Manager, Developer Engagement
Jai_Spicer | 2021-03-15 04:17:22 UTC | #10
Yeah that can also work. Is there any reason I shouldn't just use the search endpoint? Seems like unnecessary logic on my end to pull all users back and filter if the endpoint can do it.
John_Carnell | 2021-03-15 13:24:59 UTC | #11
Hi Jai,
No, you can use the search API. I just shared the CLI example in case it's something that's done on an Adhoc basis and you don't feel like writing code. :slight_smile:
Thanks, John
Jai_Spicer | 2021-03-15 21:41:36 UTC | #12
Ah yep, thanks. This is used as apart of a user creation script so its a small tweak to pull back inactive users. appreciate the additional method for adhoc requests tho.
zaidmd | 2021-04-10 14:55:22 UTC | #13
Hello
I too had the same problem but got solved after reading this thread.
Thank you everyone.
system | 2021-05-11 15:05:47 UTC | #14
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 10185