Legacy Dev Forum Posts

 View Only

Sign Up

Show as Unauthorzied, but added to view on al

  • 1.  Show as Unauthorzied, but added to view on al

    Posted 06-05-2025 19:25

    TVo1 | 2024-04-12 15:55:02 UTC | #1

    apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken(os.environ['CLIENTID'], os.environ['CLIENTSECRET']) authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)

    print(authApi.getauthorizationpermissions())

    apiinstance= PureCloudPlatformClientV2.ConversationsApi() pagesize= 5000 page_number= 1 interval= '2024-02-06T00:00:00Z/2024-02-10T00:00:00'

    try:

    Get call history

    apiresponse = apiinstance.getconversationscallshistory(pagesize=pagesize, pagenumber=pagenumber, interval=interval) print(apiresponse) except ApiException as e: print("Exception when calling ConversationsApi->getconversationscalls_history: %s\n" % e)

    Output: C:\Users\tvo1\AppData\Local\Programs\Python\Python311\python.exe C:\Users\tvo1\Python\Python\Genesys-Flask.py {'entities': [{'domain': 'analytics', 'id': None, 'name': None, 'permissionmap': {'agentConversationDetail': [{'action': 'view', 'allowsconditions': True, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'agentConversationDetail', 'label': "Query for an agent's conversation details"}], 'botAggregate': [{'action': 'view', 'allowsconditions': True, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'botAggregate', 'label': 'Query for bot aggregates'}], 'conversationAggregate': [{'action': 'view', 'allowsconditions': True, 'divisionaware': True, 'domain': 'analytics', 'entitytype': 'conversationAggregate', 'label': 'Query for conversation aggregates'}], 'conversationDetail': [{'action': 'view', 'allowsconditions': True, 'divisionaware': True, 'domain': 'analytics', 'entitytype': 'conversationDetail', 'label': 'Query for conversation details'}], 'conversationProperties': [{'action': 'index', 'allowsconditions': False, 'divisionaware': True, 'domain': 'analytics', 'entitytype': 'conversationProperties', 'label': 'Index conversation properties'}], 'dashboardConfigurations': [{'action': 'deleteActive', 'allowsconditions': False, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'dashboardConfigurations', 'label': 'Delete dashboard configurations for any active user in the org'}, {'action': 'deleteInactive', 'allowsconditions': False, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'dashboardConfigurations', 'label': 'Delete dashboard configurations for any inactive user in the org'}, {'action': 'edit', 'allowsconditions': False, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'dashboardConfigurations', 'label': 'Query for dashboard configurations'}, {'action': 'publish', 'allowsconditions': False, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'dashboardConfigurations', 'label': 'Make dashboard configurations public'}, {'action': 'view', 'allowsconditions': False, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'dashboardConfigurations', 'label': 'Query for dashboard configurations'}, {'action': 'viewPrivate', 'allowsconditions': False, 'divisionaware': False, 'domain': 'analytics', 'entitytype': 'dashboardConfigurations', 'label': 'Query for private dashboard configurations of any user in the org'}]}, 'selfuri': '/api/v2/authorization/permissions'}, {'domain': 'acdvideo', 'id': None, 'name': None, 'permissionmap': {'session': [{'action': 'view', 'allowsconditions': False, 'divisionaware': False, 'domain': 'acdvideo', 'entitytype': 'session', 'label': 'View ACD video sessions'}]}, 'selfuri': '/api/v2/authorization/permissions'}, {'domain': 'agentUI', 'id': None, 'name': None, 'permissionmap': {'defaultPanels': [{'action': 'edit', 'allowsconditions': False, 'divisionaware': False, 'domain': 'agentUI', 'entitytype': 'defaultPanels', 'label': 'Edit Agent UI default panel settings'}, {'action': 'view', 'allowsconditions': False, 'divisionaware': False, 'domain': 'agentUI', 'entitytype': 'defaultPanels', 'label': 'View Agent UI default panel settings'}]}, 'selfuri': '/api/v2/authorization/permissions'}, {'domain': 'acdscreenshare', 'id': None, 'name': None, 'permissionmap': {'chat': [{'action': 'escalate', 'allowsconditions': False, 'divisionaware': False, 'domain': 'acdscreenshare', 'entitytype': 'chat', 'label': 'Allows agent to escalate a chat to a screenshare'}], 'session': [{'action': 'view', 'allowsconditions': False, 'divisionaware': False, 'domain': 'acdscreenshare', 'entitytype': 'session', 'label': 'Allows viewing ACD screen share session'}], 'voice': [{'action': 'escalate', 'allowsconditions': False, 'divisionaware': False, 'domain': 'acdscreenshare', 'entitytype': 'voice', 'label': 'Allows agent to escalate a voice call to a screenshare'}]}, 'selfuri': '/api/v2/authorization/permissions'}, {'domain': 'alerting', 'id': None, 'name': None, 'permissionmap': {'alert': [{'action': 'add', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'alert', 'label': 'Add an alert configuration'}, {'action': 'delete', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'alert', 'label': 'Delete an alert configuration'}, {'action': 'edit', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'alert', 'label': 'Edit an alert configuration'}, {'action': 'view', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'alert', 'label': 'View alert configurations'}], 'rule': [{'action': 'add', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'rule', 'label': 'Add an alert configuration'}, {'action': 'delete', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'rule', 'label': 'Delete an alert configuration'}, {'action': 'edit', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'rule', 'label': 'Edit an alert configuration'}, {'action': 'view', 'allowsconditions': False, 'divisionaware': False, 'domain': 'alerting', 'entitytype': 'rule', 'label': 'View alert configurations'}]}, 'selfuri': '/api/v2/authorization/permissions'}], 'firsturi': '/api/v2/authorization/permissions?pageSize=25&pageNumber=1', 'lasturi': '/api/v2/authorization/permissions?pageSize=25&pageNumber=42', 'nexturi': '/api/v2/authorization/permissions?pageSize=25&pageNumber=2', 'pagecount': 42, 'pagenumber': 1, 'pagesize': 25, 'previousuri': None, 'selfuri': '/api/v2/authorization/permissions?pageSize=25&pageNumber=1', 'total': 1035} Exception when calling ConversationsApi->getconversationscallshistory: (401) Reason: Unauthorized HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '201', 'Connection': 'keep-alive', 'Date': 'Fri, 12 Apr 2024 15:54:23 GMT', 'ININ-Correlation-Id': 'a6a78557-6615-4bbe-85f1-838b1673e2c4', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 250c0cb00d06687b06322aeb6c0379f2.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'LAX50-P2', 'X-Amz-Cf-Id': 'x7xDKl0DPtcu1HVYW1F195TxjzIFXXidypaRpUEAztn1_wsdr8ZzlQ=='}) HTTP response body: {"message":"No authentication bearer token specified in authorization header.","code":"authentication.required","status":401,"contextId":"a6a78557-6615-4bbe-85f1-838b1673e2c4","details":[],"errors":[]}


    tim.smith | 2024-04-12 15:58:27 UTC | #2

    TVo1, post:1, topic:25689
    api_instance= PureCloudPlatformClientV2.ConversationsApi()

    You forgot to pass in the apiclient. Refer to the example here showing how to specify the apiclient when constructing an api instance: https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudpython/#client-credentials-grant.


    TVo1 | 2024-04-12 16:18:19 UTC | #3

    apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken(os.environ['CLIENTID'], os.environ['CLIENTSECRET']) authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)

    apiinstance= PureCloudPlatformClientV2.ConversationsApi(apiclient) pagesize= 1000 page_number= 1 interval= '2024-02-06T00:00:00Z/2024-02-10T00:00:00Z'

    try:

    Get call history

    apiresponse = apiinstance.getconversationscallshistory(pagesize=pagesize, pagenumber=page_number, interval=interval)

    apiresponse = apiinstance.getconversationscallshistory(interval=interval) pprint(apiresponse) except ApiException as e: print("Exception when calling ConversationsApi->getconversationscalls_history: %s\n" % e)

    output: {'entities': [], 'firsturi': '/api/v2/conversations/calls/history?pageSize=0&pageNumber=1', 'lasturi': '/api/v2/conversations/calls/history?pageSize=0&pageNumber=1', 'nexturi': None, 'pagecount': 0, 'pagenumber': 1, 'pagesize': 0, 'previousuri': None, 'selfuri': '/api/v2/conversations/calls/history?pageSize=0&pageNumber=1', 'total': 0}

    When i run the api from https://developer.genesys.cloud/devapps/api-explorer and execute the the time frame the output is different on the call history

    {
      "entities": [
        {
          "id": "b20905b3-ef02-40eb-8761-XXX",
          "participants": [
            {
              "id": "c94c26c8-a06a-4f38-b700-XXX",
              "name": "Northbrook IL",
              "address": "tel:+1847989XXX",
              "startTime": "2024-02-09T17:19:50.010Z",
              "endTime": "2024-02-09T17:23:26.525Z",
              "purpose": "customer",
              "direction": "inbound",
              "ani": "tel:+18479893176",
              "dnis": "tel:+16576568931",
              "disconnectType": "endpoint",
              "externalContact": {
                "id": "c72ea53d-28f6-4a9e-bbc2-XXX",
                "selfUri": "/api/v2/externalcontacts/contacts/c72ea53d-28f6-4a9e-bbc2-XXX"
              },
              "didInteract": true,
              "sipResponseCodes": []
            },

    tim.smith | 2024-04-12 17:19:09 UTC | #4

    That looks right. Client credentials don't make calls, so they don't get any call history. Your user can make calls, so your user can have call history.


    TVo1 | 2024-04-12 22:39:11 UTC | #5

    what would i use to view all call history so that i can pull the from the api? When i execute it from the developer tool i use my admin account and i don't do any calls.


    TVo1 | 2024-04-12 23:05:49 UTC | #6

    how do I change it to view on all call history from a specific time frame?


    tim.smith | 2024-04-15 13:56:09 UTC | #7

    You don't. Use analytics. https://developer.genesys.cloud/analyticsdatamanagement/analytics/


    system | 2024-05-16 13:57:00 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: 25689