Legacy Dev Forum Posts

 View Only

Sign Up

Get user status aggregate through api

  • 1.  Get user status aggregate through api

    Posted 06-05-2025 18:15

    cshiqi | 2019-06-03 06:03:08 UTC | #1

    Hi everyone,

    I would like to get the duration each user spends in each status daily. I understand that we cant get it through the endpoint stated here.

    However, I'm getting a 'Bad Request: The request could not be satisfied' error. (403 Error).

    These are my request data and header:

    request_headers = { 'Content-Type':'application/json', 'Authorization': self.token }

    requestbody = { 'interval': '2019-06-01T16:00:00.000Z/2019-06-02T16:00:00.000Z', 'granularity': 'PT12H', 'groupBy': [ 'userId' ], 'metrics': [ 'tOrganizationPresence', 'tAgentRoutingStatus' ], 'filter': { 'type': 'or', 'predicates': [ { 'dimension': 'userId', 'value': agentid } ] } }

    I also understand that Error code 403 implies that I do not have the permission to access the resource, however I am able to query for conversation details and agent details. What are the other permissions that I will need?

    Please help, thanks! :slight_smile:


    Becky_Powell | 2019-06-03 13:55:12 UTC | #2

    User aggregate queries require the analytics:userAggregate:view permission.

    FYI - you can find the required permissions for all API calls in our Developer Center. Just click on the API Resource (Analytics in your case) and then click on the endpoint to view its required permissions.

    Please let us know if you need any further assistance! -Becky


    tim.smith | 2019-06-03 15:38:03 UTC | #3

    Additionally, 403 response bodies generally indicate which permission is missing.


    cshiqi | 2019-06-11 02:01:19 UTC | #4

    Hi all,

    I have checked and I do have the permissions enabled for the oauth that I am using.

    However, I am still getting the permission error. Any ideas?

    Thanks!


    tim.smith | 2019-06-11 16:48:32 UTC | #5

    If you're using client credentials, be sure the role with the permission is assigned to the oauth client; permissions assigned to a role you're a member of have no relation to the roles assigned to client credentials.

    If you're using any other grant type, be sure the user in question has the role you're looking at.

    After verifying the role configuration and assignment, if you're still having issues, please open a case with PureCloud Care to investigate.


    cshiqi | 2019-06-12 03:41:42 UTC | #6

    tim.smith, post:5, topic:5268
    nt credentials, be sure the role with the permission is assigned to the oauth client; permissions assigned to a role you're a member of have no relation to the roles assigned to client credentials.

    If you're using any other grant type, be sure the user in question has the role you're looking at.

    After verifying the role configuration and assignment, if you're still having issues, please open a case with PureCloud Care to investigate.

    Hi Tim,

    The role with the permission is indeed assigned to the oauth client.

    I have already opened a case with PureCloud Care, however I was recommended to post the python code used to query from the endpoint here.

    def getagentstatus(self):

    print ('retrieving agent status details')

    request_headers = { 'Content-Type':'application/json', 'Authorization': self.token }

    agentids = self.agentinfo['Agent Id']

    for agentid in agentids:

    requestbody = { 'interval': '2019-06-01T16:00:00.000Z/2019-06-02T16:00:00.000Z', 'granularity': 'PT12H', 'groupBy': [ 'userId' ], 'metrics': [ 'tOrganizationPresence', 'tAgentRoutingStatus' ], 'filter': { 'type': 'or', 'predicates': [ { 'dimension': 'userId', 'value': agentid } ] } }

    response = requests.get(self.statusinfourl, headers=requestheaders, data = json.dumps(requestbody))

    Check response

    if response.statuscode != 200: print 'Failure: ' + str(response.statuscode) + ' - ' + response.reason sys.exit(response.status_code) print (response.text) print (response.content)

    print (json.dumps(request_body))

    tempagentstatus = response.json() print (tempagentstatus) tempagentstatus.tocsv('./testagent_status.csv',index=False)

    Any ideas?

    Thanks! Shi Qi


    tim.smith | 2019-06-14 17:08:17 UTC | #7

    I'm not sure why Care would ask you to post your code here. A permissions error is something generated by the PureCloud backend and is unrelated to your code except for the fact that you're using the API. Please continue to work with Care to investigate the permissions issue.


    system | 2019-07-15 17:08:20 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: 5268