Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Create Division

    Posted 06-05-2025 18:09

    Shakti_Joshi | 2024-03-19 04:59:57 UTC | #1

    Hello - I am trying to create a Division using the SDK, but getting below error:-

    import PureCloudPlatformClientV2 from PureCloudPlatformClientV2.rest import ApiException from PureCloudPlatformClientV2.configuration import Configuration from pprint import pprint from PureCloudPlatformClientV2.apis import authorization_api

    apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken( "clientid", "ClientSecret") authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient) divisionapi = authorization_api.AuthzDivision(apiclient) body = PureCloudPlatformClientV2.AuthzDivision() body.name = 'abcd'

    try:

    Create a division.

    apiresponse = divisionapi.postauthorizationdivisions(body) pprint(apiresponse)

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

    Error:-

    divisionapi = authorizationapi.AuthzDivision(apiclient) TypeError: _init__() takes 1 positional argument but 2 were given

    Kindly help me in understanding what error I am making and how to fix it,

    Warm Regards Shakti Joshi


    Declan_ginty | 2024-03-19 10:33:05 UTC | #2

    Hi,

    The post_authorization_divisions method exists on the AuthorizationApi class not the AuthzDivision object. You are also creating two AuthzDivision objects. The error is coming from this line

    divisionapi = authorization_api.AuthzDivision(apiclient)

    because you are trying to pass in the apiclient. Instead, remove the above line and call post_authorization_divisions from the authApi object like so:

    apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(CLIENT_ID, CLIENT_SECRET)
    authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)
    body = PureCloudPlatformClientV2.AuthzDivision()
    body.name = 'test name'
    body.description = "test description"
    
    try:
        api_response = authApi.post_authorization_divisions(body)
        print(api_response)
    
    except ApiException as e:
        print("Exception when calling ObjectsApi->post_authorization_divisions: %s\n" % e)

    Regards, Declan


    Shakti_Joshi | 2024-03-19 13:58:08 UTC | #3

    Thanks Declan for pointing out the error, It works now.


    system | 2024-04-19 13:58:08 UTC | #4

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