Legacy Dev Forum Posts

 View Only

Sign Up

HTTP 401 APIs > Tutorials > Querying Queue Historical Statistics

  • 1.  HTTP 401 APIs > Tutorials > Querying Queue Historical Statistics

    Posted 06-05-2025 18:08

    Redtop | 2019-08-09 01:57:23 UTC | #1

    I am studying PureCloud API.

    <1st> I begin with "OAuth Client Credentials Login Flow".

    I modefied as follows. 1.clientid = "CLIENTID" to clientid = "secret mine" 2.clientsecret = "CLIENTSECRET" to clientsecret = "secret mine" 3.# Get token com to jp

    I got message. "Failure: 401 - Unauthorized".

    I try to read source code and modefied as follows again.

      1. Get roles

    com to jp

    I got message. "Got roles", "Roles: ...", "Done"

    <2nd> Next, I try to run "Querying Queue Historical Statistics".

    I modefied as follows too. 1.clientid = "CLIENTID" to clientid = "secret mine" 2.clientsecret = "CLIENTSECRET" to clientsecret = "secret mine" 3.# Get token com to jp 4.# Get "Support" queue by name routingapi.getroutingqueues(name='Support') to routingapi.getroutingqueues(name='My Queue')

    I got message. "Failure: 401 - Unauthorized".

    Then I thought difference between <1st> and <2nd> is "Region". I try to grep "Region", then I find "purecloudregionhosts.py".

    I read Software Development Kit (SDK). (https://developer.mypurecloud.com/api/rest/client-libraries/index.html) But I can't find howto change "Region" in Python. (Only Java and .NET)

    How can I run "Querying Queue Historical Statistics".


    Redtop | 2019-08-09 03:25:24 UTC | #2

    I found setting environment in " PureCloud API SDK - Python". (https://developer.mypurecloud.com/api/rest/client-libraries/python/index.html#using_the_library)

    region = PureCloudPlatformClientV2.PureCloudRegionHosts.apnortheast1 PureCloudPlatformClientV2.configuration.host = region.getapihost

    I got message below.


    • Querying Queue Historical Statistics -

    Got token Traceback (most recent call last): File "/home/ec2-user/bin/purecloudv2.58.0.0/ikedahistoricalstatistics.py", line 62, in <module> queuedata = routingapi.getroutingqueues(name='My Queue') File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apis/routingapi.py", line 2098, in getroutingqueues callback=params.get('callback')) File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apiclient.py", line 401, in callapi responsetype, authsettings, callback) File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apiclient.py", line 219, in _callapi url = self.host + resource_path TypeError: unsupported operand type(s) for +: 'method' and 'str'

    "My Queue" is exist. I checked "/api/v2/routing/queues/divisionviews" at "https://developer.mypurecloud.jp/developer-tools/#/api-explorer".

    How can I run "Querying Queue Historical Statistics".


    anon28885283 | 2019-08-09 08:11:03 UTC | #3

    Hi RedTop,

    The getapihost is a method which means your line should be:

    PureCloudPlatformClientV2.configuration.host = region.getapihost()

    Note the parenthesis

    EDIT: We'll have the documentation updated for that.


    Redtop | 2019-08-13 01:34:47 UTC | #4

    Hi PrinceMerluza

    I really appreciate your advice.

    Then I add the code into "Querying Queue Historical Statistics" (https://developer.mypurecloud.com/api/tutorials/analytics-conversation-aggregate-query/?language=python&amp;step=1)

    <Added Code> region = PureCloudPlatformClientV2.PureCloudRegionHosts.apnortheast1 PureCloudPlatformClientV2.configuration.host = region.getapihost

    But I got Error Message Bellow. /**********************


    • Querying Queue Historical Statistics -

    Got token Traceback (most recent call last): File "/home/ec2-user/bin/purecloudv2.58.0.0/ikedahistoricalstatistics1.py", line 67, in <module> queuedata = routingapi.getroutingqueues(name='My Queue') File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apis/routingapi.py", line 2098, in getroutingqueues callback=params.get('callback')) File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apiclient.py", line 401, in callapi responsetype, authsettings, callback) File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apiclient.py", line 219, in _callapi url = self.host + resourcepath TypeError: unsupported operand type(s) for +: 'method' and 'str'


    /

    And I found another way, "QueueEntityListing getroutingqueues". (https://developer.inindca.com/api/rest/client-libraries/python/RoutingApi.html#get_routing_queues)

    Then I add the code into " getroutingqueues".

    <Added Code> region = PureCloudPlatformClientV2.PureCloudRegionHosts.apnortheast1 PureCloudPlatformClientV2.configuration.host = region.getapihost

    <Modify Code> name = 'My Queue' active = True (Because Original code "active = true" get error message)

    But I got Error Message Bellow. /**********************


    • Querying Queue Historical Statistics -

    Got token Traceback (most recent call last): File "/home/ec2-user/bin/purecloudv2.58.0.0/ikedahistoricalstatistics2.py", line 79, in <module> apiresponse = apiinstance.getroutingqueues(pagesize=pagesize, pagenumber=pagenumber, sortby=sortby, name=name, active=active, divisionid=divisionid) File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apis/routingapi.py", line 2098, in getroutingqueues callback=params.get('callback')) File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apiclient.py", line 401, in callapi responsetype, authsettings, callback) File "/home/ec2-user/bin/purecloudv2.58.0.0/PureCloudPlatformClientV2/apiclient.py", line 219, in _callapi url = self.host + resourcepath TypeError: unsupported operand type(s) for +: 'method' and 'str'


    /

    Please tell me the right way to run "Querying Queue Historical Statistics" or "QueueEntityListing getroutingqueues".


    Redtop | 2019-08-13 02:04:49 UTC | #5

    Hi PrinceMerluza

    I really, really appreciate your advice.

    I read your message again, and i try modifiing my code with "()".

    I got right responce!!


    system | 2019-09-13 02:04:52 UTC | #6

    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: 5742