TypeError: can only concatenate str (not "PermissionCollectionEntityListing") to str

Hi,

I am working on python scripts that use below codes:.

create an instance of the API class

api_instance = PureCloudPlatformClientV2.AnalyticsApi()

try:

Get all view export requests for a user

api_response = api_instance.get_analytics_reporting_exports_metadata()
pprint(api_response)

the part of get_analytics_reporting_exports_metadata() throws an error of "TypeError: can only concatenate str (not "PermissionCollectionEntityListing") to str".

Any ideas on how to resolve it?

Thanks!

Hi Klarence,

I am unable to replicate this issue with the code you have shown. Can you show more of your code please (minus any confidential info)?

Regards,
Declan

Hello,

Thank you for your response. here it is:

import PureCloudPlatformClientV2
from PureCloudPlatformClientV2.rest import ApiException
from pprint import pprint

# >> START oauth-client-credentials-step-1 
CLIENT_ID = 'xx'
CLIENT_SECRET = 'xx'
ENVIRONMENT = 'xx' # eg. mypurecloud.com

region = PureCloudPlatformClientV2.PureCloudRegionHosts.us_west_2
PureCloudPlatformClientV2.configuration.host = region.get_api_host()

apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(CLIENT_ID,
                                                                                          CLIENT_SECRET)
authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)

# Configure OAuth2 access token for authorization: PureCloud OAuth
PureCloudPlatformClientV2.configuration.access_token = authApi.get_authorization_permissions() 
# or use get_client_credentials_token(...), get_saml2bearer_token(...) or get_code_authorization_token(...)

# create an instance of the API class
api_instance = PureCloudPlatformClientV2.AnalyticsApi()

try:
    # Get all view export requests for a user
    api_response = api_instance.get_analytics_reporting_exports_metadata()
    pprint(api_response)

except ApiException as e:
    print("Exception when calling ConversationsApi->get_analytics_conversations_details: %s\n" % e)

What version of the python sdk are you using?

Hi Klarence,

This function authApi.get_authorization_permissions() return an object PermissionCollectionEntityListing which you are trying to set your access token to. https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudpython/AuthorizationApi#get_authorization_permissions

Instead send your apiclient to the analytics api like so:

apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(CLIENT_ID, CLIENT_SECRET)

api_instance = PureCloudPlatformClientV2.AnalyticsApi(apiclient);

try:
    api_response = api_instance.get_analytics_reporting_exports_metadata()
    pprint(api_response)
except ApiException as e:
    pprint("Exception when calling AnalyticsApi->get_analytics_reporting_exports_metadata: %s\n" % e)

Regards,
Declan

Hi Declan,

Thank you for your response. This works!

Klarence

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