Shakti_Joshi | 2024-03-19 04:55:49 UTC | #1
Hello I am trying to add multiple wrapup codes to a Queue using below code,:-
wrapupcodeid= ["123-abcd", "5468-abcde" ]
queueid='e03cf2a0-b982'
create an instance of the API class
routingapi = routing_api.RoutingApi(apiclient)
for name in wrapupcodename: try:
Update wrap-up code to Queue
body = PureCloudPlatformClientV2.WrapUpCodeReference() body.name = name
apiresponse = routingapi.postroutingqueuewrapupcodes(queueid,body) pprint(apiresponse) except ApiException as e: print("Exception when calling RoutingApi->postrouting_wrapupcodes: %s\n" % e)
getting below error:-
Exception when calling RoutingApi->postroutingwrapupcodes: (400) Reason: Bad Request HTTP response body: {"message":"The request could not be understood by the server due to malformed syntax.","code":"bad.request","status":400,"contextId":"229d0a23-ff04-45e6-a9cc-441b3b5c253d","details":[],"errors":[]}
Could you help me understanding what exactly am I doing wrong and how to fix it?
Declan_ginty | 2024-03-19 10:56:18 UTC | #2
Hi,
post_routing_queue_wrapupcodes takes a list of WrapUpCodeReference objects whereas you are sending in a single object. Instead you'll need to create the WrapUpCodeReference inside the loop and add it to a list and then after the loop has finished, call the api with the list of WrapUpCodeReferences like so:
wrap_up_codes = []
for name in wrapup_code_name:
wrap_up_code = PureCloudPlatformClientV2.WrapUpCodeReference()
# Add properties
wrap_up_codes.append(wrap_up_code)
try:
api_response = routingApi.post_routing_queue_wrapupcodes(queueId,wrap_up_codes)
print(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->post_routing_wrapupcodes: %s\n" % e)
Regards, Declan
Shakti_Joshi | 2024-03-19 21:10:40 UTC | #3
Here is the updated code, but I am getting a different error now:-
apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken("ClientID,"ClientSecret") authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)
List of wrap-up code names
wrapupcodeids = [ "0e182817", "546815f3", ]
Create an API Instance
wrapupcode = PureCloudPlatformClientV2.WrapUpCodeReference()
api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient)
queue ID where you want to add Wraup Codes
queueid='e03cf2a0'
Placeholder to hold WrapupCodeReference Objects
wrapupcodes = []
for codeid in wrapupcodeids : wrapupcode=PureCloudPlatformClientV2.WrapUpCodeReference() wrapupcodes.append(wrapup_code)
wrapupcodes.append(wrapupcode)
try: apiresponse = apiinstance.postroutingqueuewrapupcodes(queueid,wrapupcodes) pprint(apiresponse) except ApiException as e: print("Exception when calling RoutingApi->postroutingwrapupcodes: %s\n" % e)
Error:-
Exception when calling RoutingApi->postroutingwrapupcodes: (400) Reason: Bad Request HTTP response body: {"message":"No valid wrap-up codes were provided in the request.","code":"bad.request","status":400,"messageWithParams":"No valid wrap-up codes were provided in the request.","messageParams":{},"contextId":"5ecd4436-6e46-4449-897f-0f79e9561535","details":[],"errors":[]}
Process finished with exit code 0
I have also tried with wrapupcode name, but I don't think that's the issue, as the function is expecting a wrapup Code ID.
KIndly help.
Declan_ginty | 2024-03-20 12:02:01 UTC | #4
Hi,
Inside your loop you will need to set the id of WrapUpCodeReference to be the id of the wrapup code you wish to add to the routing queue. If you already have a list of the ids you can simply modify your code like so:
for code_id in wrapup_code_ids:
wrap_up_code = PureCloudPlatformClientV2.WrapUpCodeReference()
wrap_up_code.id = code_id
wrap_up_codes.append(wrap_up_code)
Regards, Declan
Shakti_Joshi | 2024-03-20 13:42:53 UTC | #5
Thanks Declan - This helped me in fixing the missing piece. Now its working.
Warm Regards Shakti Joshi
system | 2024-04-20 13:43:37 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: 25266