Help updating data table via Data Action

Hi Everyone.

I need some help. This is my first post here, so please bear with me :).
We are in the process of onboarding to Genesys Cloud, and I'm trying to understand these data actions. I'm far from a Coding expert, and JSON is fairly new to me, but I have been able to get some successful "get" events done. And by using the https://developer.genesys.cloud/developer-tools/#/api-explorer I am able to achieve what I want to achieve.

Lastly I fell upon this post: Data Action - Update DataTable and thought I found my answer, but I just can't get my "put" action to work.

So I hope you can help me.

I created a fresh table with a key and a text column. I then manually added a row, and now I try to update it via a data action. Using the API-explorer I can update it, but not via a data action.
I'm entering the following:
image

And I receive the following error:

{
  "message": "Processing the Request Body Template resulted in invalid JSON.",
  "code": "internal.server.error",
  "status": 500,
  "messageParams": {},
  "contextId": "4e76a80c-5f8a-4d16-a1b9-3f20a8ea20b0",
  "details": [
    {
      "errorCode": "ACTION.PROCESSING"
    }
  ],
  "errors": [
    {
      "message": "Unrecognized token 'Louis': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)\"{\n \"Key\": 1234,\n \"Text\": Louis nummer}\"; line: 3, column: 15]",
      "code": "INTERNAL_SERVER_ERROR",
      "status": 500,
      "messageParams": {},
      "details": [],
      "errors": []
    }
  ]
}

I tried with entering "Louis nummer" instead, to force it to be a string, but it gives me a new error on step 8.

My JSON looks like this:

{
  "name": "HenrikWebserviceTest - Exported 2022-06-28 @ 14:39",
  "integrationType": "custom-rest-actions",
  "actionType": "custom",
  "config": {
    "request": {
      "requestUrlTemplate": "/api/v2/flows/datatables/${input.datatableid}/rows/${input.Key}",
      "requestType": "PUT",
      "headers": {
        "Content-Type": "application/json"
      },
      "requestTemplate": "{\n \"Key\": ${input.Key},\n \"Text\": ${input.Text}}"
    },
    "response": {
      "translationMap": {
        "Key": "$.[key]",
        "text": "$.[text]"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"Key\": ${input.Key},\"Text\": ${input.Text}}"
    }
  },
  "contract": {
    "input": {
      "inputSchema": {
        "title": "DataWriter",
        "type": "object",
        "properties": {
          "Key": {
            "type": "string"
          },
          "Text": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "output": {
      "successSchema": {
        "type": "object",
        "properties": {
          "Key": {
            "type": "string"
          },
          "Text": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  },
  "secure": false
}

I hope you can help me further, as beeing able to update data tables solves a lot of our requests to the platform.

Thanks in advance
Henrik

Hi Henrik,

I would guess that the issue that you are having is that you need to put "escaped quotes" around the key and text in your request and response templates. So in the simple UI mode go from

{
 "Key": ${input.Key},
 "Text": ${input.Text}
}

to something like this:

{
 "Key": "${input.Key}",
 "Text": "${input.Text}"
}

--Jason

1 Like

thank you very much. I did have a gut feeling it was a simple syntax issue somewhere. :slight_smile:

Thanks