How to add Wrapup code using Python SDK

I am trying to run below Python Code:-

api_instance = PureCloudPlatformClientV2.RoutingApi();
data = {"name": "ABC- HFPU-In_Progress"}

body = PureCloudPlatformClientV2.WrapupCodeRequest(data)

try:
# Create a wrap-up code
api_response = api_instance.post_routing_wrapupcodes(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->post_routing_wrapupcodes: %s\n" % e)

And I am getting below error:-

body = PureCloudPlatformClientV2.WrapupCodeRequest(data)

TypeError: init() takes 1 positional argument but 2 were given

How to fix this error?

Hi @Shakti_Joshi

I was able to get the code to work by defining the body like this instead:

body = PureCloudPlatformClientV2.WrapupCodeRequest()
body.name = 'ABC- HFPU-In_Progress'

Hope this helps

-Charlie

Thanks a lot @charlie.conneely , It actually did, could you help me in understand more why you did what you did? This will help me expand on this knowledge on future codes as well.

Also as small request, can we improve the documentation and provide proper examples , for example below is the python code provided in the developer center, and its nowehere near to what the final code looks like:-

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

Configure OAuth2 access token for authorization: PureCloud OAuth

PureCloudPlatformClientV2.configuration.access_token = 'your_access_token'

or use get_client_credentials_token(...), get_saml2bearer_token(...), get_code_authorization_token(...) or get_pkce_token(...)

create an instance of the API class

api_instance = PureCloudPlatformClientV2.RoutingApi();
body = PureCloudPlatformClientV2.WrapupCodeRequest() # WrapupCodeRequest | WrapupCode

try:
# Create a wrap-up code
api_response = api_instance.post_routing_wrapupcodes(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->post_routing_wrapupcodes: %s\n" % e)

Hi @Shakti_Joshi

The wrap up code class does not accept a map parameter to set all request body values at once. I will investigate further to see if there is a helper function in the python SDK to allow for that. In the meantime, you could pass the whole request body to the post function like this:

body = {
  'name': 'test wrapupcode',
  'division': {
    'id': '<division ID>'
  }
}

try:
  api_response = api_instance.post_routing_wrapupcodes(body)
  # ...

Are you referring to the example here on the API explorer? As far as I can see, all that is missing are the lines demonstrating how to set the fields for the wrapup code object (i.e. body.name = 'the name'). I will raise this internally to see if more lines can be added to futher help the end user.

-Charlie

1 Like

Thanks, if the suggestion can be implemented for almost all the APIs, it will expedite in development process.

The suggestion is to put an example of how to use the code, like you have showed in your previous reply.

Warm Regards
Shakti Joshi

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