We’re getting a 400 Bad Request when attempting to add a phone number to a DNC list via the REST Proxy action in . The documentation for adding phone numbers to a DNC list states the request body “should be a JSON array of strings representing the phone numbers to add to the DNC list”.
The nice-cxone-python library serializes the list of phone numbers as expected, but the API rejects it. It appears the session manager isn’t properly encoding the payload.
{
"errors": [
{
"message": "Invalid request body",
"code": "INVALID_REQUEST_BODY"
}
]
}
The Python code looks like this:
import requests
import json
dnc_list_id = "YOUR_DNC_LIST_ID"
dnc_numbers = ["+15551234567", "+15559876543"]
url = f"https://YOUR_CXONE_ORG.genesyscloud.com/api/v2/outbound/dnclists/{dnc_list_id}/phonenumbers"
headers = {
"Authorization": "Bearer YOUR_BEARER_TOKEN",
"Content-Type": "application/json"
}
try:
response = requests.post(url, headers=headers, data=json.dumps(dnc_numbers))
response.raise_for_status()
print("DNC update successful")
except requests.exceptions.HTTPError as errh:
print(f"HTTP Error: {errh}")
except requests.exceptions.ConnectionError as errc:
print(f"Connection Error: {errc}")
except Exception as err:
print(f"An unexpected error occurred: {err}")
The requests library works fine outside of - so it’s definitely something with how the nice-cxone-python SDK handles serialization within the flow.