mayarashwan | 2021-11-25 12:23:35 UTC | #1
Hello,
I'm implementing a custom data action that has an output a number and an object. The issue is when i try to call this data action in architect, the output is the number only as attached in the screenshot
 |
 |
when i tried to change the translation map, the output appears correctly but without the number { "translationMap": { "result": "$.properties" }, "translationMapDefaults": {}, "successTemplate": "${result}" } So i need to add in the translationMap the number but when i try to add or change in the translationMap so it includes the callid, it doesn't work and throws this error 11. Validate output against schema: JSON failed schema validation for the following reasons: instance type (integer) does not match any allowed primitive type (allowed: ["object"]) { "translationMap": { "idValue": "$.callid"
}, "translationMapDefaults": {}, "successTemplate": "${idValue}" } Any idea how to fix this issue so all the variables can appear in architect ?
Jerome.Saint-Marc | 2021-11-26 11:03:56 UTC | #2
Hello,
Just to confirm - is the response to your API request having following schema (from JSON perspective)?
{ "properties": { "campaign": "mycampaign", "adgroup": "myadgroup", "adtitle": "myadtitle", "adtext": "myadtext", "page": "mypage" }, "callid": 1234 }
If yes, that's interesting. The fact that your object attribute name is "properties" is causing an issue to the Data Action - as it is using a keyword also used in the output contract schema (i.e. properties).
What you can do, to have your Data Action work, is the following.
Set your Output Contract as follows (click on JSON display - next to Simple - and you can copy what's below):
{ "type": "object", "properties": { "callid": { "type": "number" }, "campaign": { "type": "string" }, "adgroup": { "type": "string" }, "adtitle": { "type": "string" }, "adtext": { "type": "string" }, "page": { "type": "string" } }, "additionalProperties": true }
Set your Response Configuration as follows:
{ "translationMap": { "callidValue": "$.callid", "campaignValue": "$.properties.campaign", "adgroupValue": "$.properties.adgroup", "adtitleValue": "$.properties.adtitle", "adtextValue": "$.properties.adtext", "pageValue": "$.properties.page" }, "translationMapDefaults": { "callidValue": "0", "campaignValue": "\"\"", "adgroupValue": "\"a default value\"", "adtitleValue": "\"\"", "adtextValue": "\"\"", "pageValue": "\"\"" }, "successTemplate": "{ \"callid\": ${callidValue}, \"campaign\": ${campaignValue}, \"adgroup\": ${adgroupValue}, \"adtitle\": ${adtitleValue}, \"adtext\": ${adtextValue}, \"page\": ${pageValue} }" }
If your API response always contains all the attribute names, the translationMapDefaults can be left empty (i.e. {}). I have just included them in case some of the attribute names are not always present in the API response and you want to have a default value in this case (0 as default value for callid, "a default value" as default value for addgroup, and empty strings - i.e. "" - for the other output).
Regards,
mayarashwan | 2021-11-26 11:06:12 UTC | #3
Hi Jerome, yes this is the output and your solution is working perfectly. Thanks for your help.
system | 2021-12-27 11:06:41 UTC | #4
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: 12765