Terraform Plan - Data Action

The terraform plan is failing consistently when attempting to deploy a Data Action within an Architect flow - specifically, a flow that uses a Data Action to POST to an external API. It appears the parameter type being passed from terraform doesn’t align with what the Data Action expects - the API is rejecting the value as invalid. We’ve confirmed the API itself functions correctly when tested directly through Postman, so it’s not an issue with the endpoint.

It’s not a simple string escaping problem. The parameter in question is intended to be a JSON payload, and terraform is attempting to serialize it as a string literal - which the Data Action then interprets as a string, instead of a JSON object. It’s a baffling issue since the Data Action configuration itself allows for JSON input.

Here’s the relevant snippet from the terraform plan output. Note the double escaping - which seems to be where the conversion goes wrong. The Great Cloud’s API expects a JSON string, and this is… not that.

 # genesys_cloud_architect_dataaction.data_action will be updated in-place
 resource "genesys_cloud_architect_dataaction" "data_action" {
 id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
 name = "External API POST"
 description = "Posts data to an external API"
 request_payload = "{\"someKey\":\"\\\"{\\\"value\\\":\\\"someValue\\\"}\\\"\"}" # <--- This is the problem
 ...
 }

The request_payload attribute clearly shows the double escaping. We’re using the genesys_cloud provider version 2.18.0, and running terraform v1.5.2. I’ve tried encoding the JSON payload to base64 within terraform, but that only adds another layer of encoding issues. I’ve also tried using the jsonencode() function, but it doesn’t seem to resolve the issue. There isn’t an apparent option within the provider to specify the content type as JSON, which feels like a critical oversight.

this happen when type is string but api want integer. we do A/B test with different parameter types and ML scoring fail when data type mismatch.

try change to this in terraform:

input_parameters {
 name = "myParam"
 type = "STRING"
}

is the api error 400 or 422? maybe check the older thread about data action types.

1 Like

That fix resolved the issue. I adjusted the parameter type to an integer within the Terraform configuration, and the Great Cloud now accepts the payload.