Legacy Dev Forum Posts

 View Only

Sign Up

Possible error in python sample code for region selection

  • 1.  Possible error in python sample code for region selection

    Posted 06-05-2025 18:08

    Paul_Lewis | 2019-12-11 21:08:30 UTC | #1

    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.useast1 PureCloudPlatformClientV2.configuration.host = region.getapihost

    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 "billableusagetest.py", line 15, in <module> apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken(clientid,clientsecret) File "hidden\REST API\mocking\lib\site-packages\PureCloudPlatformClientV2\apiclient.py", line 102, in getclientcredentialstoken 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


    tim.smith | 2019-12-11 22:59:14 UTC | #2

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


    system | 2020-01-11 22:59:15 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: 6697