Additional Properties error, adding new row in datatable using data action

Hi Team,

I am trying to add new row to a datatable through data action. Below is the request template.

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

I am getting additional properties not allowed error.

{
"message": "The request could not be understood by the server due to malformed syntax.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "340264f1-ac23-4809-9936-bffd7d341a02",
"details": [
{
"errorCode": "ACTION.REMOTE_ENDPOINT"
}
],
"errors": [
{
"message": "REST call for action execute failed. Message: Request to backend service failed. Response from web service: {"message":"Additional properties are not allowed ('stringoutput', 'datatableid' were unexpected)\n\nFailed validating 'additionalProperties' in schema:\n {'$schema': 'http://json-schema.org/draft-04/schema#',\n 'additionalProperties': False,\n 'datatableId': 'e1d58615-1bf9-4080-a355-a292307c4026',\n 'properties': {'key': {'$id': '/properties/key',\n 'displayOrder': 0,\n 'maxLength': 256,\n 'minLength': 1,\n 'title': 'item',\n 'type': 'string'},\n 'string output': {'$id': '/properties/string output',\n 'displayOrder': 1,\n 'maxLength': 262144,\n 'minLength': 0,\n 'title': 'string_output',\n 'type': 'string'}},\n 'required': ['key'],\n 'title': 'testing api',\n 'type': 'object'}\n\nOn instance:\n {'datatableid': 'e1d58615-1bf9-4080-a355-a292307c4026',\n 'key': '26a141c1-6c30-4530-bd91-9797ce25d65e',\n 'string output': '',\n 'stringoutput': 'hi mansi'}","code":"flows.datatables.schema.exception","status":400,"messageParams":{},"contextId":"3b164e76-6fa2-4497-9a98-6b110ce409ca","details":[],"errors":[]} [340264f1-ac23-4809-9936-bffd7d341a02]",
"code": "BAD_REQUEST",
"status": 400,
"messageParams": {},
"details": [],
"errors": []
}
]
}

I checked this on developer tools and its working fine there but failing in data actions.
Please help me solve this error, guide me on whats wrong.

Thank you

Have you tried escaping the quotes and removing your new line character? Something like:

"{ \"datatableid\":\"${input.datatableid}\", \"stringoutput\":\"${input.stringoutput}\", \"Key\": \"${input.Key}\"}"

Hi Patrick,

I tried removing \n :
"requestTemplate": "{ "datatableid" : "${input.datatableid}", "stringoutput": "${input.stringoutput}", "Key": "${input.Key}}"}"

I get the same error as additional properties:

"Additional properties are not allowed ('stringoutput', 'datatableid' were unexpected)

Tried removing quotes, I get an error as below:
"message": "Unexpected character ('d' (code 100)): was expecting double-quote to start field name.

Thank you

Did you try to use my suggested string of escaping quotes with a backslash?

Hello,

The body of the POST /api/v2/flows/datatables/${input.datatableid}/rows is not supposed to contain the Data Tabale Id (datableid). The datatableid is passed in the url.

Also, reading the Data Action error you get (your first post), it seems you have defined a table with only 2 columns: 'Key' of course and 'string output' (there is a space between string and output).
When you created the table custom field, you have set it to "string output". After the custom field is created, you can only modify its label (you have set it to string_output) but the field name/key can't be changed.

So I think your Request Configuration should look like this:

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

Regards,

Thanks Jerome,

Yes, you are absolutely correct. I understood what was going wrong. Its now working as expected.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.