Malformed Syntax with Integration Actions
Closed this issue · 5 comments
While trying to deploy a new integration action I am getting an error message : API Error: 400 - The request could not be understood by the server due to malformed syntax. I have deployed numerous other Genesys resources without issue. I have copied the code from the documentation (https://registry.terraform.io/providers/MyPureCloud/genesyscloud/latest/docs/resources/integration_action), the same way I did for the other resources. I have also run terraform validate and it says the format is correct.
I believe the error may have something to do with jsonencode aspect of this resource, but the error message does not provide much information for me to debug with.
Any assistance is appreciated. Thanks.
Hi Scase011,
What I normally do is create the data action manually in Genesys Cloud and then use the CLI to extract the JSON and copy it the CX as Code component. I would suggest you do this and compare that with what you have in the CX as Code component. That is the first thing I would do. A 400 indicates the JSON is malformed. We take what is coming in JSON and just pass it through in the component.
I would encourage you to also take a look at our https://github.com/genesysCloudDevOps repository. We have a ton of CX as Code data actions you can look at and compare. Also, in the future, I would recommend you post to our forum (https://developer.genesys.cloud/forums) with a question like this. We have a ton of developers across the company who monitor the forum.
Thanks,
John Carnell
Hello John,
I appreciate the response. I have tried this deployment with the input and output JSONs copied from an action within Genesys. I have also tried by copying the contracts from one of the modules in the code repository you linked. No matter what I input here, I always get this malformed syntax error. I have also tried hard coding the integration id, just in case that reference was causing an issue, but still no luck. Below is one example of the code I have tried.
resource "genesyscloud_integration_action" "example-action" {
name = "Example Action"
category = "Genesys Cloud Data Action"
integration_id = data.genesyscloud_integration.example_integration_name.id
contract_input = jsonencode({
"type" = "object",
"additionalProperties" = true,
"properties" = {
"body" = {
"type" = "string"
}
}
})
contract_output = jsonencode({
"type" = "object",
"additionalProperties" = true,
"properties" = {
"conversationId" = {
"type" = "string"
}
}
})
}
Does anything jump out as incorrect?
Hi,
Your JSON in the JSONEncode is malformed. JSON does not use = (HCL does). You json encode should look something like this:
contract_input = jsonencode({
"type": "object",
"additionalProperties": true,
"properties": {
"body": {
"type": "string"
}
}
})
Anytime you see a JSONEncode it needs to be valid JSON.
Thanks,
John
That would make sense, in the Terraform documentation it has =, so I just kept it with that format. However, I did notice something weird after making the changes you proposed. I make the change in my main.tf :
resource "genesyscloud_integration_action" "example-action" {
name = "Example Action"
category = "Genesys Cloud Data Action"
integration_id = data.genesyscloud_integration.example_integration_name.id
contract_input = jsonencode({
"type": "object",
"additionalProperties": true,
"properties": {
"body": {
"type": "string"
}
}
})
contract_output = jsonencode({
"type": "object",
"additionalProperties": true,
"properties": {
"conversationId": {
"type": "string"
}
}
})
}
However, I am still receiving the same error and when I run terraform apply, I see it returning to the previous syntax :
genesyscloud_integration_action.example-action will be created
- resource "genesyscloud_integration_action" "example-action" {
- category = "Genesys Cloud Data Action"
- contract_input = jsonencode(
{
+ additionalProperties = true
+ properties = {
+ body = {
+ type = "string"
}
}
+ type = "object"
}
) - contract_output = jsonencode(
{
+ additionalProperties = true
+ properties = {
+ conversationId = {
+ type = "string"
}
}
+ type = "object"
}
) - id = (known after apply)
- integration_id = "56c10f8a-4434-4935-811a-7759f385c7ba"
- name = "Example Action"
- secure = false
}
Would the fact that it is displaying with the = after running terraform apply cause it to return the malformed syntax error?
By the way, I made sure that the file was changed and it was not just running with the pre-save syntax.
Unable to reproduce after multiple variations an attempts. Closing