Data Action - Parameter Update Failing

Hey everyone,

purecloudplatformclientv2 is giving a 400 Bad Request when updating a data action parameter via the API. It’s happening on a flow that’s been stable for months. We’re on NICE CXone, using the Python SDK version 12.1.0.

The documentation states “parameters are strongly typed and must match the data type defined in the data action,” but the type I’m sending - a string - matches what’s defined in the data action configuration. The endpoint is /api/v2/flows/activities/{activity_id}/dataactions/{data_action_id}/parameters/{parameter_id}.

Here’s the relevant part of the call:

data_action_parameters = {
 "parameter_id": "some_param_id",
 "value": "some_value"
}
data_action_api = api_client.DataActionApi()
response = data_action_api.update_data_action_parameter(activity_id="some_activity_id", data_action_id="some_data_action_id", parameter_id=data_action_parameters["parameter_id"], body=data_action_parameters)

The error message is just “Bad Request” with no details in the response body. It’s not a permissions issue, I checked that.

Looks like the SDK might be encoding the payload incorrectly - try explicitly setting Content-Type: application/json.

import httpx
import json

url = "your_url"
headers = {"Content-Type": "application/json"}
data = {"parameterKey": "your_key", "parameterValue": "your_value"}

response = httpx.patch(url, headers=headers, content=json.dumps(data))

hope this helps someone

1 Like
{"message":"Bad Request","code":400,"details":[{"field":"parameterKey","message":"must match pattern [a-zA-Z0-9_]+","code":"invalid_format"}]}-that rings a bell, usually happens when the key itself has invalid characters. The documentation specifies alphanumeric and underscores only, so check the parameterKey against that regex, because even a stray hyphen will trigger the 400. Here's a quick Python test to validate the key before sending it: `import re; key = "your_key"; match = re.match(r"^[a-zA-Z0-9_]+$", key); print(match)`-if that returns None, you've found your problem.

That said, the encoding suggestion from the earlier reply is worth checking, though I suspect it's the key itself. We've seen a similar issue with the Genesys Cloud API where the parser is very strict on the key format, while the value is more forgiving. To rule that out, try constructing the payload as a string and explicitly setting the Content-Type header as they suggested-`import httpx; import json; url = "your_url"; headers = {"Content-Type": "application/json"}; data = '{"parameterKey": "your_key", "parameterValue": "your_value"}'; response = httpx.patch(url, headers=headers, content=data)`-if that clears the 400, you'll know it wasn't the encoding, and can focus on the key validation.

That fix with the Content-Type header didn’t help, but the comment about the parameter key is right - I forgot to mention we did recently add a hyphen to the key name in the data action config. purecloudplatformclientv2 isn’t flagging that, but the API is. I’ll remove the hyphen and test.