Shakti_Joshi | 2024-03-13 05:40:22 UTC | #1
I am trying to run below Python Code:-
apiinstance = PureCloudPlatformClientV2.RoutingApi(); data = {"name": "ABC- HFPU-InProgress"}
body = PureCloudPlatformClientV2.WrapupCodeRequest(data)
try:
Create a wrap-up code
apiresponse = apiinstance.postroutingwrapupcodes(body) pprint(apiresponse) except ApiException as e: print("Exception when calling RoutingApi->postrouting_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?
charlie.conneely | 2024-03-13 15:27:33 UTC | #2
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
Shakti_Joshi | 2024-03-14 01:00:36 UTC | #3
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.accesstoken = 'youraccess_token'
or use getclientcredentialstoken(...), getsaml2bearertoken(...), getcodeauthorizationtoken(...) or getpkcetoken(...)
create an instance of the API class
api_instance = PureCloudPlatformClientV2.RoutingApi(); body = PureCloudPlatformClientV2.WrapupCodeRequest() # WrapupCodeRequest | WrapupCode
try:
Create a wrap-up code
apiresponse = apiinstance.postroutingwrapupcodes(body) pprint(apiresponse) except ApiException as e: print("Exception when calling RoutingApi->postrouting_wrapupcodes: %s\n" % e)
charlie.conneely | 2024-03-20 14:04:05 UTC | #4
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
Shakti_Joshi | 2024-03-21 02:47:55 UTC | #5
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
system | 2024-04-21 02:48:52 UTC | #6
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: 25162