Klarence_Alindogan | 2023-10-04 16:41:50 UTC | #1
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
apiresponse = apiinstance.getanalyticsreportingexportsmetadata() pprint(api_response)
the part of getanalyticsreportingexportsmetadata() throws an error of "TypeError: can only concatenate str (not "PermissionCollectionEntityListing") to str".
Any ideas on how to resolve it?
Thanks!
Declan_ginty | 2023-10-04 16:58:27 UTC | #2
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
Klarence_Alindogan | 2023-10-04 17:34:27 UTC | #3
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)
Declan_ginty | 2023-10-04 17:29:20 UTC | #4
What version of the python sdk are you using?
Declan_ginty | 2023-10-04 17:51:50 UTC | #5
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
Klarence_Alindogan | 2023-10-04 18:45:59 UTC | #6
Hi Declan,
Thank you for your response. This works!
Klarence
system | 2023-11-04 18:46:01 UTC | #7
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: 22361