API Calls/Query for conversation aggregates

Hi,

This forum is really helpful.

My company uses Genesys solutions.
I can login to https://login.mypurecloud.com/

I am a developer and one of my internal teams needs my help in extracting all possible data from purecloud.
I learned using the Analytics Post API it is possible thanks to Ronan

I began with postman to understand how this works Get Real-Time and Historical Data with the Analytics API

Challenges:
With Basic Auth i get error "error": "invalid_request"

Do I need some kind of auth token from login.mypurecloud.com/oauth/token to send a Post request to

https://api.mypurecloud.com/api/v2/analytics/conversations/aggregates/query

I want to write a python script with fixed 1 minute interval which will extract data from cloud and store it under in our local DB

Will OAuth Client Credentials Login Flow Using Python be helpful to extract data from purecloud?

Thanks
Ashish

In OAuth Client Credentials Login Flow Using Python Do I need to supply credentials I use for login.mypurecloud.com?

Example:

CLIENT_ID = os.environ['test_user']
CLIENT_SECRET = os.environ['mypassword']
ENVIRONMENT = os.environ['mypurecloud.com'] # eg. mypurecloud.com

Can I get the client ID etc. information from developer-tools ?

I do not see Integrations under Admin I was following the link create-an-oauth-client

Tried this query
I am getting the following message

    "message": "Unable to perform the requested action. You are missing the following permission 'analytics:queueObservation:view' in the provided division(s).",
    "code": "missing.division.permission",
    "status": 403,

What and whom do i need to request the required access? I assume this will prevent me from using python script also?

Overall I need help in setting an API call using python script (but to learn i was trying to use postman) can somebody please guide?

I do not see Integrations under Admin I was following the link create-an-oauth-client

You'd need admin privileges to create an OAuth client.

What and whom do i need to request the required access? I assume this will prevent me from using python script also?

The OAuth client needs to have the analytics:queueObservation:view permission to call that API. You can ask your organization admin to add the required permissions to the OAuth client.

Overall I need help in setting an API call using python script (but to learn i was trying to use postman) can somebody please guide?

Firstly you'll probably want to authenticate using client credentials

My answer to this forum post shows how to use a similar analytics API. The best thing to do is use the analytics query builder to build the queries you'll be sending and then translate it to python.

1 Like

Thank you Ronan!
May I know where exactly I will get GENESYS_CLOUD_CLIENT_ID, GENESYS_CLOUD_CLIENT_SECRET from?

apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(os.environ['GENESYS_CLOUD_CLIENT_ID'],
os.environ['GENESYS_CLOUD_CLIENT_SECRET'])
authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)
print(authApi.get_authorization_permissions())

Thanks
Ashish

Hi Ashish,

These are environment variables you would set in your environment containing your Oauth Client Credential Id and OAuth Client Credential Secret. These values are defined in the Genesys Cloud UI. Instructions for setting up the OAuth Client can be found here.

Thanks,
John Carnell
Manager, Developer Engagement

1 Like

Thank you @John_Carnell
Either I have to have admin privileges or an organization Admin can add this for me, right?

Thanks
Ashish

Hi Ashish,

That is correct.

  • John

Thank you John!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.