Armands_Bunkovskis | 2020-05-25 18:32:56 UTC | #1
Hi! I'm trying to create first data action to insert data inta datatable. In current setup I'g getting error "REST call for action execute failed. Message:Request to backend service failed. Response from web service: {"message":"'{input.ChosenLanguage}' is not of type 'integer'\n\nFailed validating 'type' in schema['properties']['ChosenLanguage']:\n {'$id': '/properties/ChosenLanguage',\n 'displayOrder': 1,\n 'maximum': 999999999999999,\n 'minimum': -999999999999999,\n 'title': 'ChosenLanguage',\n 'type': 'integer'}\n\nOn instance['ChosenLanguage']:\n '{input.ChosenLanguage}'","code":"flows.datatables.schema.exception","status":400,"messageParams":{},"contextId":"24c53a5f-27c7-471c-b471-a223d312893f","details":[],"errors":[]} [f90c9fe1-cc13-45fe-977f-d9daee9c43f6]" This is logical as ChosenLanguage is defined as Integer. If I remove "" in Request Body Template (so it looks: {"ChosenLanguage":{input.ChosenLanguage},"Key":"{input.PhoneNumber}"} , then error message is: **7. Resolve request body template: Request body is malformed. Error: Unexpected character ('i' (code 105)): was expecting double-quote to start field name at [Source: (String)"{"ChosenLanguage":{input.ChosenLanguage},"Key":"{input.Phone_Number}"}"; line: 1, column: 22]
How should I format Request Body Template for integer? If this Chosen_Language is defined as string in both data table and contract, then Action runs OK (but I need integer...)
Any help is much appreciated
Action export is given below: { "name": "UpdateLanguageTable - Exported 2020-05-25 @ 19:50", "integrationType": "purecloud-data-actions", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "/api/v2/flows/datatables/d36e1691-eaf9-4745-aae8-5cdef76b90b0/rows", "requestType": "POST", "headers": {}, "requestTemplate": "{\"ChosenLanguage\":\"{input.ChosenLanguage}\",\"Key\":\"{input.PhoneNumber}\"}" }, "response": { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" } }, "contract": { "input": { "inputSchema": { "title": "PhoneNumber", "type": "object", "properties": { "PhoneNumber": { "type": "string" }, "ChosenLanguage": { "type": "integer" } }, "additionalProperties": true } }, "output": { "successSchema": { "title": "Update table", "type": "object", "properties": {}, "additionalProperties": true } } }, "secure": false }
mikehardie | 2020-05-26 04:14:14 UTC | #2
Your post request must include a field called KEY - the value for this is the key for the record you are inserting
Jerome.Saint-Marc | 2020-05-26 04:48:55 UTC | #3
Hello,
When you include the export of your Action in a question, please format it using the "</>" (Preformatted text) - otherwise some characters get lost (dollar sign, backslash, ...).
Regarding your question, I think you are missing the dollar sign in front of your input parameters in the requestTemplate.
This is what I have entered, as JSON, in my Data Action (change the datatableId - xxxxxxxxxxxxxxxxxxx in my example below)
Input Contract:
{ "type": "object", "required": [ "PhoneNumber", "ChosenLanguage" ], "properties": { "PhoneNumber": { "type": "string" }, "ChosenLanguage": { "type": "integer" } }, "additionalProperties": true }
Output Contract:
{ "type": "object", "properties": {}, "additionalProperties": true }
Request Configuration:
{ "requestUrlTemplate": "/api/v2/flows/datatables/xxxxxxxxxxxxxxxxxxx/rows", "requestType": "POST", "headers": { "Content-Type": "application/json" }, "requestTemplate": "{\"ChosenLanguage\":${input.ChosenLanguage},\"key\":\"${input.Phone_Number}\"}" }
Response Configuration:
{ "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" }
Regards,
Armands_Bunkovskis | 2020-05-26 06:06:54 UTC | #4
Thanks. Missing $ was the case.
system | 2020-06-26 06:06:58 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: 7881