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, brand_name, omni_channel 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"