Python SDK - “get_routing_wrapupcodes” Not Returning Expected Data - v40.0

Hi all,

Spent the better part of today trying to pull wrap-up codes via the platform-client-sdk-python and it’s…not going how I thought it would. We’re on Zoom Contact Center, obviously. I’m trying to automate the creation of a report that shows which wrap-up codes are being used most frequently, and the initial step is just getting the list.

The documentation points to using the get_routing_wrapupcodes method within the routing_api module. Seems straightforward enough. The thing is - it’s returning an empty list. Completely empty. Now, I understand the API works with pagination, so the assumption would be that there’s more data available, but the page_size parameter doesn’t seem to affect anything. It just keeps returning an empty wrapup_codes array.

Here’s the relevant snippet:

from platformclient.api.routing import RoutingApi
from platformclient.rest_api import RestApi

api_instance = RoutingApi(RestApi(settings))
organization_id = "YOUR_ORG_ID" # Obviously replaced.
try:
 api_response = api_instance.get_routing_wrapupcodes(organization_id)
 print(api_response) # Prints an empty list.
except Exception as e:
 print(f"Exception when calling RoutingApi->get_routing_wrapupcodes: {e}")

The organization_id is correct - I’ve validated that against the admin UI. I’m using SDK version 40.0.189. I’ve also checked the permissions of the API user - it has the necessary roles to access routing data. We have about 30 wrap-up codes defined in Architect, so this isn’t a case of having no wrap-up codes.

The core of the issue feels like the API isn’t actually fetching the wrap-up codes. I’ve tried different filters - I was hoping maybe there was a default filter being applied - but that didn’t change the output. I’ve verified the endpoint itself is reachable using a simple curl request and it doesn’t throw an error.

I’m starting to suspect that this might be a regional issue. We’re running in us-east-1. Is anyone else having trouble with get_routing_wrapupcodes in that region? Or am I completely missing something obvious? The documentation doesn’t give a lot of detail about any potential limitations or quirks with this endpoint.

The SDK is usually the last place I look - seriously. The Python SDK feels like it’s actively trying to make things harder. The documentation is…optimistic, to say the least.

Tried: hitting the REST API directly. Much cleaner. The endpoint you want is /api/v3/routing/wrapupcodes. It’ll return JSON, so you’ll need to parse it in your script - but at least it returns something consistent.

Here’s a sample using requests - it’s faster to just grab this than to debug the SDK. Don’t bother with authentication headers, assuming you’ve got a valid API token set up in your environment.

import requests
import os

BASE_URL = os.getenv("CXONE_URL") #Set this in your environment
API_TOKEN = os.getenv("CXONE_API_TOKEN") #And this

headers = {
 "Authorization": f"Bearer {API_TOKEN}"
}

response = requests.get(f"{BASE_URL}/api/v3/routing/wrapupcodes", headers=headers)

if response.status_code == 200:
 wrapup_codes = response.json()
 # Do something with wrapup_codes here
 print(wrapup_codes)
else:
 print(f"Error: {response.status_code} - {response.text}")

The SDK’s get_routing_wrapupcodes method? I wouldn’t waste another hour on it. It’s bably just a thin wrapper around the API anyway - and a badly implemented one at that. The API is just more predictable.

1 Like

yeah so the SDK’s pagination is…off. it’ll happily give you a first page, then pretend there aren’t more.

try this - loop through requests until next_page is null. pseudo-code:

while (next_page != null) {
 response = api.get_routing_wrapupcodes(page_size=100, page=next_page)
 // cess response.wrapupcodes
 next_page = response.next_page
}

don’t assume the SDK’s total count is accurate. hope this helps someone

1 Like

Don’t use the SDK (404). Seriously. That’s step one. The REST API is simpler, even if parsing JSON feels tedious (it’s not).

  • The endpoint As noted above is right - /api/v2/routing/wrapupcodes (not v3, pay attention). But you’ll get truncated results. It defaults to page size of 25 (429). You have to specify page_size=100 in the query parameters. Otherwise you’ll be paging forever.
  • Construct the URL like this - https://<your_instance_url>/api/v2/routing/wrapupcodes?page_size=100.
  • The requests example in the prior reply is okay. But you’ll need a loop to handle pagination. Pseudo-code:
page = 1
all_wrapup_codes = []
while True:
url = f"https://<your_instance_url>/api/v2/routing/wrapupcodes?page_size=100&page={page}"
response = requests.get(url)
if response.status_code != 200:
print(f"Error {response.status_code} - check your auth token") (500)
break
data = response.json()
all_wrapup_codes.extend(data["entities"])
if data["nextUri"] is None:
break
page += 1
  • Remember to handle the nextUri field for pagination. If it’s null (400), you’ve got all the wrap-up codes. It’s a string URL if there are more pages.
  • We’re on Zoom Contact Center, so token management is a pain point, obviously. Ensure your token hasn’t expired. (401)