Legacy Dev Forum Posts

 View Only

Sign Up

Data Action Request Json Configuration sub schemas

  • 1.  Data Action Request Json Configuration sub schemas

    Posted 06-05-2025 18:41

    SoporteHT1 | 2019-04-09 14:27:43 UTC | #1

    Hi everyone, we have a REST API Web service definition with following structure:

    { "card": { "name": "TESTING", "number": "4157881234569874", "expiryMonth": "08", "expiryYear": "23", "cvv": "121" }, "totalAmount": 11, "currency": "USD", "isDeferred": false } In json request configuration we defined follow structure:

    { "title": "The Root Schema", "type": "object", "required": [ "card", "totalAmount", "currency", "isDeferred" ], "properties": { "card": { "type": "string", "title": "The Card Schema", "required": [ "name", "number", "expiryMonth", "expiryYear", "cvv" ] }, "totalAmount": { "type": "number", "title": "totalAmount" }, "currency": { "type": "string", "title": "currency" }, "isDeferred": { "type": "boolean", "title": "isDeferred" } } }

    When testing from IVR with web service connector, we´re received the next error message:

    "message": "REST call for action execute failed. Message:Request to backend service failed. Response from web service: {\"code\":\"K001\",\"message\":\"Invalid body request."

    Is possible that json schema request definition is invalid? How we can manage sub structure (card) inside json definition request?

    Thanks for you help.

    Greetings...


    Jason_Mathison | 2019-04-09 15:34:11 UTC | #2

    For schema problems I typically start with an online JSON schema generator, like https://jsonschema.net/ (I have no relationship to them and offer no warranty of any kind). Putting in your example body will spit out a schema for you.

    The big thing that stands out comparing your schema to the auto-generated one is that you have "card" as a string type when it should be an object.

    Our Data Action configuration will often not like some of the fluff that auto-generated schemas add, however they will help you get the right types and structure.

    I didn't get to the point of trying to test your action since there looked to be a significant schema issue. If you need further help please include an export of your action (with any sensitive parts replaced with place holders) as well as the output of using test mode (also replacing anything sensitive).

    --Jason


    SoporteHT1 | 2019-04-09 16:25:42 UTC | #3

    Thanks Jason, I get following json schema from online tool:

    { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "card": { "type": "object", "required": [ "name", "number", "expiryMonth", "expiryYear", "cvv" ], "properties": { "name": { "type": "string" }, "number": { "type": "string" }, "expiryMonth": { "type": "string" }, "expiryYear": { "type": "string" }, "cvv": { "type": "string" } } }, "totalAmount": { "type": "integer" }, "currency": { "type": "string" }, "isDeferred": { "type": "boolean" } } }

    When we tried to configure this, we get following error:

    But in online validator , the schema is correct? Why this happens inside configuration Actions PureCloud?

    Thanks again for your support!!!


    Jason_Mathison | 2019-04-09 17:06:56 UTC | #4

    Sorry, I didn't know what you were trying to accomplish. Data Actions do not support complex input contracts: https://help.mypurecloud.com/articles/add-contracts-custom-actions-integrations/

    In order to build a complex request body you would need to use key-value pairs for your input parameters, and then use a request template to put them into an object. https://help.mypurecloud.com/articles/request-configuration-data-actions/

    If you are having further issues please attach an export of your action.


    SoporteHT1 | 2019-04-10 20:32:33 UTC | #5

    Thanks for information Jason, we decide implement a middle ware to simplify our process.


    Jason_Mathison | 2019-04-10 20:44:21 UTC | #6

    Sorry to hear that you had to stand up a middle ware service to make this doable. Please let us know any suggestions you have for us to make this better.

    --Jason


    system | 2019-05-11 20:44:22 UTC | #7

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


    This post was migrated from the old Developer Forum.

    ref: 4941