REST Proxy PUT to /api/v2/outbound/campaigns/{id}/dnc returns 400

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.

POST /api/v2/outbound/dnclists/{dncListId}/phonenumbers
Content-Type: application/json

["+15551234567", "+15559876543"]

The current approach is like attempting to use a key for a specific room on a building’s exterior door. The endpoint cited in the original post doesn’t exist for this function. To modify a Do Not Call list, the request must target the specific resource collection rather than the campaign object. It’s a matter of addressing the database record directly instead of the orchestration layer.

If the 400 Bad Request persists, check the payload against these common failure modes:

Error Trigger Technical Root Cause Resolution
Invalid Format Non-E.164 formatted strings Ensure numbers start with + and country code
Wrong Method Using PUT instead of POST Change HTTP method to POST
Schema Mismatch Passing an object instead of an array Wrap strings in a JSON array

This follows the general REST architectural pattern seen in RFC 7231 where the resource path defines the action. Use the POST method on the phone numbers endpoint to append entries.

1 Like

PureCloudPlatformClientV2 doesn’t care about your intent if the endpoint is wrong. You can’t use a PUT on a resource that doesn’t exist in the schema.

Use POST /api/v2/outbound/dnclists/{dncListId}/phonenumbers instead. It’s a simple collection append, not a full resource replacement.