Legacy Dev Forum Posts

 View Only

Sign Up

Module 'PureCloudPlatformClientV2.api_client' has no attribute 'call_api'

  • 1.  Module 'PureCloudPlatformClientV2.api_client' has no attribute 'call_api'

    Posted 06-05-2025 18:32

    Gurbaj_Bhatia | 2024-08-29 10:52:41 UTC | #1

    Hi Team,

    I am trying to fetch Routing Queues from: /api/v2/routing/queues while referring to: https://developer.genesys.cloud/routing/outbound/create-outbound-campaign-guide

    But getting below error:

    File "\PureCloudPlatformClientV2\apis\routingapi.py", line 4760, in getroutingqueues response = self.apiclient.callapi(resourcepath, 'GET', AttributeError: module 'PureCloudPlatformClientV2.apiclient' has no attribute 'callapi'

    Python script

    import os
    
    from PureCloudPlatformClientV2 import api_client
    from PureCloudPlatformClientV2 import AuthorizationApi
    from PureCloudPlatformClientV2.apis import scripts_api, outbound_api, routing_api
    
    # Credentials
    CLIENT_ID = os.getenv('GENESYS_CLOUD_CLIENT_ID')
    CLIENT_SECRET = os.getenv('GENESYS_CLOUD_CLIENT_SECRET')
    
    apiclient = api_client.ApiClient().get_client_credentials_token(CLIENT_ID, CLIENT_SECRET)
    authApi = AuthorizationApi(apiclient)
    
    
    # Set your own values here
    CONTACT_LIST_NAME = "SET_ME"
    QUEUE_NAME = "SET_ME"
    SCRIPT_NAME = "SET_ME"
    
    # Get contact list by name
    outbound_api = outbound_api.OutboundApi(apiclient)
    routing_api = routing_api.RoutingApi(api_client)
    contact_lists = outbound_api.get_outbound_contactlists(name=CONTACT_LIST_NAME)
    print(f"Contact Lists: {contact_lists}")
    
    if (len(contact_lists.entities) == 0 or
            contact_lists.entities[0].name != CONTACT_LIST_NAME):
        raise ValueError("Failed to find Contact List")
    
    contact_list_id = contact_lists.entities[0].id
    
    print(f"Found contact list {contact_list_id}")
    
    # Get queue by name
    queue = routing_api.get_routing_queues(name=QUEUE_NAME)
    print(f"Queues: {queue}")
    
    if (len(queue.entities) == 0 or
            queue.entities[0].name != QUEUE_NAME):
        raise ValueError("Failed to Queue!")
    
    queue_id = queue.entities[0].id
    print(f"Found queue {queue_id}")
    
    # Get script by name
    script = scripts_api.get_scripts(name=SCRIPT_NAME)
    print(f"Scripts: {script}")
    
    if (len(script.entities) == 0 or
            script.entities[0].name != SCRIPT_NAME):
        raise ValueError("Failed to script!")
    
    script_id = script.entities[0].id
    print(f"Found script {script_id}")

    PureCloudPlatformClientV2 version: 210.0.0


    Declan_ginty | 2024-08-29 11:30:21 UTC | #2

    Hi,

    When you initialised the routingapi you passed in `apiclient` instead of apiclient which was what you named the variable above.

    Regards, Declan


    system | 2024-09-29 11:31:14 UTC | #3

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