Legacy Dev Forum Posts

 View Only

Sign Up

Malformed Syntax on translation map for POST request

  • 1.  Malformed Syntax on translation map for POST request

    Posted 06-05-2025 18:44

    ceej_vms | 2023-09-25 18:32:45 UTC | #1

    I have a Web Service data action that points to an external API. This API is a POST request that allows us to pass a phone number, email address, brandname, omnichannel within the request body.

    My request header

    {
     "requestUrlTemplate": "https://someurl.io/api/someapi",
     "requestType": "POST",
     "headers": {
      "client_id": "foo",
      "client_secret": "bar",
      "Content-Type": "application/json"
     },
     "requestTemplate": "{\n \"patient\": {\n  \"phone_number\": \"${input.phone_number}\",\n  \"email_address\": null,\n  \"brand_name\": \"${input.brand_name}\",\n  \"omni_channel\": \"${input.omni_channel}\"\n  }\n}"
    }

    Here's my request body template

    {
     "patient": {
      "phone_number": "${input.phone_number}",
      "email_address": null,
      "brand_name": "${input.brand_name}",
      "omni_channel": "${input.omni_channel}"
      }
    }

    and my input contract

    {
     "title": "patient",
     "type": "object",
     "properties": {
      "phone_number": {
       "type": "string"
      },
      "email_address": {
       "type": "string"
      },
      "brand_name": {
       "type": "string"
      },
      "omni_channel": {
       "type": "string"
      }
     },
     "additionalProperties": true
    }

    We will expect the following response from the API

    Here's my expected output contract:

    {
      "title": "result",
      "type": "array",
      "properties": {},
      "items": {
        "title": "active_case",
        "type": "object",
        "properties": {
          "case_id": {
            "type": "string"
          },
          "case_owner_email": {
            "type": "string"
          },
          "case_stage": {
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }

    Here's the translation map

    {
      "translationMap": {
        "oCaseId": "$.responseData[*].case_id",
        "oCaseOwnerEmail": "$.responseData[*].case_owner_email",
        "oFirstName": "$.responseData[*].first_name",
        "oLastName": "$.responseData[*].last_name",
        "oCaseStage": "$.responseData[*].case_stage"
      },
      "translationMapDefaults": {},
      "successTemplate": {
        "title": "result",
        "type": "array",
        "properties": {},
        "items": {
          "title": "active_case",
          "type": "object",
          "properties": {
            "case_id": "${oCaseId}",
            "case_owner_email": "${oCaseOwnerEmail}",
            "first_name": "${oFirstName}",
            "last_name": "${oLastName}",
            "case_stage": "${oCaseStage}"
          },
          "additionalProperties": true
        }
      }
    }

    While the translation map above is syntactically correct I'm unable to save the data action because I'm receiving the following error

    "The request could not be understood by the server due to malformed syntax"


    Jason_Mathison | 2023-09-25 18:34:23 UTC | #2

    Hi CJ,

    The issue appears to be with your success template, which looks very odd. It seems to be formatted like a schema more that a response object. It might be as simple as pulling out the properties part of that response object and ending up with something like

    ` "successTemplate": "{\"caseid\": \"${oCaseId}\", \"caseowneremail\": \"${oCaseOwnerEmail}\", \"firstname\": \"${oFirstName}\", \"lastname\": \"${oLastName}\", \"casestage\": \"${oCaseStage}\" }"`

    --Jason


    ceej_vms | 2023-09-26 14:39:19 UTC | #3

    Thank for the reply Jason!

    I replaced the success template and ended with this

    {
      "translationMap": {
        "oCaseId": "$.result[*].case_id",
        "oCaseOwnerEmail": "$.result[*].case_owner_email",
        "oFirstName": "$.result[*].first_name",
        "oLastName": "$.result[*].last_name",
        "oCaseStage": "$.result[*].case_stage"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"case_id\": \"${oCaseId}\", \"case_owner_email\": \"${oCaseOwnerEmail}\", \"first_name\": \"${oFirstName}\", \"last_name\": \"${oLastName}\", \"case_stage\": \"${oCaseStage}\" }"
    }

    However I'm getting a schema validation error since my output requires multiple objects listed in an array. Here's an example output with dummy data that I'm trying to transform

    {
      "result": [
        {
          "active_case": {
            "case_id": "00001069",
            "case_owner_email": "chuck.testa@test.com",
            "case_stage": "Welcome",
            "first_name": "Mister",
            "last_name": "Meseeks"
          }
        }
      ]
    }

    I tried specifying it with

    {
      "translationMap": {
        "oCaseId": "$.result[*].case_id",
        "oCaseOwnerEmail": "$.result[*].case_owner_email",
        "oFirstName": "$.result[*].first_name",
        "oLastName": "$.result[*].last_name",
        "oCaseStage": "$.result[*].case_stage"
      },
      "translationMapDefaults": {},
      "successTemplate": [
        {
          "case_id": "${oCaseId}",
          "case_owner_email": "${oCaseOwnerEmail}",
          "first_name": "${oFirstName}",
          "last_name": "${oLastName}",
          "case_stage": "${oCaseStage}"
        }
      ]
    }

    But that's also giving me malformed syntax errors. Any chance for next steps?


    ceej_vms | 2023-09-26 19:58:37 UTC | #4

    Update on this - I was able to resolve the translation mapping since the response data I was expecting is an array that expects multiple objects called active cases.

    Here's my update translation map

    "translationMap": {
      "oCaseId": "$.result[*].active_case.case_id",
      "oCaseOwnerEmail": "$.result[*].active_case.case_owner_email",
      "oFirstName": "$.result[*].active_case.first_name",
      "oLastName": "$.result[*].active_case.last_name",
      "oCaseStage": "$.result[*].active_case.case_stage"
    }

    same success template as you posted Jason.

    I can resolve the translation map step when testing but this time its failing on apply output transformation

    {
      "message": "Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('0' (code 48)): was expecting comma to separate Object entries\n at [Source: (String)\"{\"case_id\": \"[ \"00001069\" ]\", \"case_owner_email\": \"[ \"lucian.blebea@vmsbiomarketing.com\" ]\", \"first_name\": \"[ \"Lonnie\" ]\", \"last_name\": \"[ \"Beer\" ]\", \"case_stage\": \"[ \"Welcome\" ]\" }\"; line: 1, column: 18]'\n Template:'{\"case_id\": \"${oCaseId}\", \"case_owner_email\": \"${oCaseOwnerEmail}\", \"first_name\": \"${oFirstName}\", \"last_name\": \"${oLastName}\", \"case_stage\": \"${oCaseStage}\" }'.",
      "code": "bad.request",
      "status": 400,
      "messageParams": {},
      "contextId": "0701eff6-bbb3-4d8d-a3a4-7fdce9b66846",
      "details": [
        {
          "errorCode": "ACTION.PROCESSING"
        }
      ],
      "errors": []
    }

    system | 2023-10-27 19:58:38 UTC | #5

    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: 22196