Updating data tables with data actions

Hi, I am trying to create data action to update data table.

I followed Help updating data table via Data Action - Data Actions - Genesys Cloud Developer Forum and created a da table with two columns and it worked.
when I created another data table with four columns and modified the data action its giving below error. can some one provide guidance on what mistake I am doing here.

{
"name": "Update DataTable - Exported 2024-04-29 @ 20:55",
"integrationType": "purecloud-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "/api/v2/flows/datatables/datatableid/rows",
"requestType": "POST",
"headers": {
"Content-Type": "application/json"
},
"requestTemplate": "{\n "InteractionID": ${input.InteractionID},\n "UserID": ${input.UserID},\n "UserName": ${input.UserName},\n "Queue": ${input.Queue}}"
},
"response": {
"translationMap": {
"InteractionID": "$.[InteractionID]",
"UserID": "$.[UserID]",
"UserName": "$.[UserName]",
"Queue": "$.[Queue]"
},
"translationMapDefaults": {},
"successTemplate": "{"InteractionID": ${input.InteractionID},"UserID": ${input.UserID},"UserName": ${input.UserName},"Queue": ${input.Queue}}"
}
},
"contract": {
"input": {
"inputSchema": {
"title": "Interaction Details",
"type": "object",
"properties": {
"InteractionID": {
"type": "string"
},
"UserID": {
"type": "string"
},
"UserName": {
"type": "string"
},
"Queue": {
"type": "string"
}
},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"title": "Interaction Details",
"type": "object",
"properties": {
"InteractionID": {
"type": "string"
},
"UserID": {
"type": "string"
},
"UserName": {
"type": "string"
},
"Queue": {
"type": "string"
}
},
"additionalProperties": true
}
}
},
"secure": false
}

Error Message:
Execute: The request could not be understood by the server due to malformed syntax.

  • REST call for action execute failed. Message: Request to backend service failed. Response from web service: {"message":"'' is too short\n\nFailed validating 'minLength' in schema['properties']['key']:\n {'$id': '/properties/key',\n 'displayOrder': 0,\n 'maxLength': 256,\n 'minLength': 1,\n 'title': 'InteractionID',\n 'type': 'string'}\n\nOn instance['key']:\n ''","code":"flows.datatables.schema.exception","status":400,"messageParams":{},"contextId":"datatableid","details":[],"errors":[]} [f221f1ae-b9d6-494e-9ec5-fa05877b8fb5]

Can't read those json templates in that format.

Checks:
You supplied the Key field, it has to be provided.
You populated ALL the fields with current values, if you not modifying them.

Your URL looks to be missing the rowId and shows as POST, when its a PUT?

Sample from mock of mine
image

Hi @SimonBrown Type POST is correct.

I am using POST
/api/v2/flows/datatables/{datatableId}/rows

Below is working copy of mine, when made a small change its not working(that is where I am not able to identify my mistake.

{
"requestUrlTemplate": "/api/v2/flows/datatables/datatableid/rows",
"requestType": "POST",
"headers": {
"Content-Type": "application/json"
},
"requestTemplate": "{\n "Key": ${input.Key},\n "Text": ${input.Text}}"
}

You said updating rows, that's PUT operation.
Post is for creating new rows.

Not tried the POST version myself. May get chance to have a quick test and reply

Ok. Just did through API explorer fine.

I would recommend you make the JSON body up in the Request body.
Remember the "KEY" field is for the ID field you have, which could be called something completely different.
The rest of the fields need to match and remember they are case sensitive.

Below is one I just did for my datatable test

{
"Integer": 0,
"Description": "Test POST entry",
"Decimal": 1.12,
"Boolean": true,
"String2": "String 2 value",
"key": "Simon",
"String1": "String 1 value"
}

For data table that has schema

Thank you @SimonBrown

Key field is what i missed. In my example as I named 'key' as 'InteractionID' I am using 'InteractionID' as field value instead of 'Key'.

Thank you for your quick assistance on this !

Hi @SimonBrown ,

I am getting failure when I am using this data action in Architect flow. could you suggest what might causing this.

when I am passing input as 'Literal' (hard coded entry) it is working, when using variable, its filing. also I can see Flow.conversationId is getting value and able to print it, however data table update is failing.

Thank you !

when I tried some other data action( getting user presence ) in architect flow, it is working as expected.

image

Hi Simon,

never mind, this got fixed after correcting the syntax of request template.

Thank you !