Jacou | 2017-08-08 20:48:29 UTC | #1
Hello, I am using the wfm management units api to retrieve the list of users using client credentials. The problem is that some of the user IDs returned by the wfm management unit API call return 404 when I try to get the user details. In which circumstances would this occur?
1. Obtaining list of MU
I use the following API to retrieve the management units:
query = "https://api.mypurecloud.com/api/v2/workforcemanagement/managementunits" response = requests.get(query, headers=header)
2. Then I loop through the resulting MUs to obtain the user IDs:
query = "https://api.mypurecloud.com/api/v2/workforcemanagement/managementunits/" + mu_id + "/users" response = requests.get(query, headers=header)
3. Finally I loop through the resulting agents to obtain the user details:
print '\n\n**** Agents: *******' for entity in response.json()['entities']: agentfound = getuserdetails(header, entity['id']) print entity['id'] + " - " + agentfound
def getuserdetails(header, user_id):
Get user
query = "https://api.mypurecloud.com/api/v2/users/" + user_id response = requests.get(query, headers=header)
Check response
if response.status_code == 200: return response.json().get('name', 'Not found')
else: print 'Failure: ' + str(response.status_code) + ' - ' + response.reason return "Not found"
When running this, I will get the details of the users but quite often obtain a 404 on obtaining the details. Trying to understand if the WFM managementunit API could be returning list of agents that are no longer existent. thanks
tim.smith | 2017-08-08 20:51:17 UTC | #2
Can you provide the correlation ID from the response header of one of the requests that returned a 404 and the request that gave you that user ID?
Jacou | 2017-08-08 21:06:16 UTC | #3
Ok here is an example:
I called the wfm api to get users part of MU: 47abb000-b3b7-730d-2f07-3ea92f8e5441. That gave me the following header:
{'Content-Length': '7317', 'Pragma': 'no-cache', 'Expires': '0', 'inin-ratelimit-allowed': '300', 'inin-ratelimit-count': '48', 'ININ-Correlation-Id': '0f88e322-7e64-4347-b650-b8bb2311a10f', 'Connection': 'keep-alive', 'inin-ratelimit-reset': '14', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Date': 'Tue, 08 Aug 2017 21:01:34 GMT', 'Content-Type': 'application/json'}
Then after 10 successful loop to get agent details, this userid failed with a 404: e982626c-42ca-4656-8b8c-4d1ce4373e0a
{'Content-Length': '168', 'Pragma': 'no-cache', 'Expires': '0', 'inin-ratelimit-allowed': '180', 'inin-ratelimit-count': '54', 'ININ-Correlation-Id': 'be5d973c-7783-4846-8764-11ff0c538f82', 'Connection': 'keep-alive', 'inin-ratelimit-reset': '1', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Date': 'Tue, 08 Aug 2017 21:01:48 GMT', 'Content-Type': 'application/json'}
Let me know if you need the details. thanks.
tim.smith | 2017-08-08 21:18:54 UTC | #4
Can you check to see if one of the users that's returning a 404 is deleted? You can use GET /api/v2/users/{userid}?state=deleted
Jacou | 2017-08-08 21:40:05 UTC | #5
tim.smith, post:4, topic:1657
GET /api/v2/users/{userid}?state=deleted
Yep, ok that works. I get the details of these agents when I use state=deleted.
Anyway I can specify that I only want "active" agents when querying the management unit?
tim.smith | 2017-08-09 13:39:29 UTC | #6
WFM doesn't currently update the management units when a user is deleted. Until that is implemented, you'll need to maintain the management unit's users by hand. Whenever you need to delete a user from the system, be sure to delete them from the WFM management units they're in as well.
I've created WFM-3030 for WFM to track user deletions and update the MUs accordingly.
Jacou | 2017-08-09 13:53:57 UTC | #7
Thanks Tim, for now adding a check on the deleted state is a good workaround for us.
system | 2017-09-09 13:54:03 UTC | #8
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: 1657