Possible error in python sample code for region selection

Re: https://developer.mypurecloud.com/api/rest/client-libraries/python/

There is an example for setting the host using the enumeration which has a typo

region = PureCloudRegionHosts.us_east_1
PureCloudPlatformClientV2.configuration.host = region.get_api_host

Note that this will set the value of PureCloudPlatformClientV2.configuration.host to a method

What was likely intended is:
PureCloudPlatformClientV2.configuration.host = region.get_api_host()

If used as per the example, there will be an issue for the user when attempting to create an api client:

apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(client_id,client_secret)

Traceback (most recent call last):
  File "billable_usage_test.py", line 15, in <module>
    apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(client_id,client_secret)
  File "hidden\REST API\mocking\lib\site-packages\PureCloudPlatformClientV2\api_client.py", line 102, in get_client_credentials_token
    url = re.sub(r'\/\/(api)\.', '//login.', self.host) + '/oauth/token'
  File "C:\Program Files (x86)\Python38-32\lib\re.py", line 208, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object

Thanks for catching that. Will get the examples template updated.

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