Legacy Dev Forum Posts

 View Only

Sign Up

Call to get list of queues does not return any data

  • 1.  Call to get list of queues does not return any data

    Posted 06-05-2025 18:08

    CDLROUSER | 2019-07-16 00:27:18 UTC | #1

    Hi,

    I am new to the PureCloud environment. We intend to acquire the PureCloud data into our data warehouse environment. The following python code was written to test the calls to the API. Unfortunately the code executes fine but I don't get any data. If I execute the API call in the API Explorer I do get the expected result. Help much appreciated.

    import base64, sys, requests import json import time import pprint

    Configure OAuth2 access token for authorization: PureCloud OAuth

    OAuth when using Client Credentials

    clientid = "XXXX" clientsecret = "XXX" authorization = base64.b64encode(bytes(clientid + ":" + clientsecret, "ISO-8859-1")).decode("ascii")

    Prepare for POST /oauth/token request

    authrequestheaders = { "Authorization": f"Basic {authorization}", "Content-Type": "application/x-www-form-urlencoded" } authrequestbody = { "granttype": "clientcredentials" }

    Get token

    print("before token") authresponse = requests.post("https://login.mypurecloud.com.au/oauth/token", data=authrequestbody, headers=authrequest_headers)

    print("after token")

    Check response

    if authresponse.statuscode == 200: print("Got token") else: print(f"Failure: { str(authresponse.statuscode) } - { authresponse.reason }") sys.exit(authresponse.status_code)

    accesstoken = authresponse.json()["accesstoken"] print(accesstoken) requestHeaders = { "Content-Type": "application/json", "Authorization": "bearer" + " " + str(access_token) }

    print("-------------------------------------------------------------") print("- Listing all queues -") print("-------------------------------------------------------------")

    response = requests.get('https://api.mypurecloud.com.au/api/v2/routing/queues?pageSize=27', headers=requestHeaders) if response.statuscode == 200: print("Got Queues") responseJson = response.json() pprint.pprint(json.dumps(responseJson, indent=6)) else: print ('Failure: ' + str(response.statuscode) + ' - ' + str(response.reason)) sys.exit(response.status_code)

    The result that I get when I run the above script is as follows:

    /usr/lib/python3/dist-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.25.3) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning) before token after token Got token


        • Listing all queues -

    Got Queues ('{\n' ' "entities": [],\n' ' "pageSize": 27,\n' ' "pageNumber": 1,\n' ' "total": 0,\n' ' "firstUri": "/api/v2/routing/queues?pageSize=27&pageNumber=1",\n' ' "selfUri": "/api/v2/routing/queues?pageSize=27&pageNumber=1",\n' ' "lastUri": "/api/v2/routing/queues?pageSize=27&pageNumber=1",\n' ' "pageCount": 0\n' '}')


    tim.smith | 2019-07-16 20:03:26 UTC | #2

    Is there any reason you're not using the Python SDK?

    If you're getting a successful response with no results, my guess is that your client credentials don't have appropriate permissions for divisions. See Fine Grained Access Control and the resource center link at the top of the page for more info about divisions.


    CDLROUSER | 2019-07-16 22:17:21 UTC | #3

    Hi Tim,

    Thanks for the response. The issue was resolved by generating a new secret key.

    I have got another program that uses the SDK and now with the new key works very well.

    Samir


    system | 2019-08-16 22:17:24 UTC | #4

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