How to write JSON in Data Action

I want to ask a very basic question.

I want to use Data Action to make a request, and the Body is composed as follows.
{
"object":
{
"key1": "value1",
"key2": "value2",
}
}

When I set it in the Action Contracts of GenesysCloud, it prompted an error. Could you please help me with this error.

Hello,

The Input Contract only accepts string, number, integer and boolean parameters under the main/top object.

What you can do is to configure your Action Configuration Request to manipulate/transform the request body.

Assuming that key1 and key2 are parameters with string values (as shown in the Body you included in your post), you can set your Input Contract to (following is the JSON view of Input Contract):

{
  "type": "object",
  "properties": {
    "key1": {
      "type": "string"
    },
    "key2": {
      "type": "string"
    }
  },
  "additionalProperties": true
}

And leverage these input parameters when defining the request body of your Request Configuration (following is the JSON view of Request Configuration):

{
  "requestUrlTemplate": "https://yourWebserver/query,
  "requestType": "POST",
  "headers": {
    "Content-Type": "application/json"
  },
  "requestTemplate": "{ \"object\": { \"key1\": \"${input.key1}\", \"key2\": \"${input.key2}\" } }"
}

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.