successTemplate errors

Just cannot seem to get my translation/successTemplate to work.
Trying to return "name" from a database table

{
"translationMap": {
"name": "$..name"
},
"translationMapDefaults": {},
"successTemplate": "{"name": ${successTemplateUtils.firstFromArray(${name})}}"
}

data action test results in...
Validate output against schema: JSON failed output schema validation for the following reasons: Schema: # @/properties/name. Error location: /name. instance type (object) does not match any allowed primitive type (allowed: ["string"])

using rawResult returns
{
"Count": 1,
"Items": [
{
"date": {
"S": "12/1/2000"
},
"name": {
"S": "Jon Doe"
},
"customerid": {
"S": "12345"
}
}
],
"ScannedCount": 1
}

Hello,

Please post/share what you have defined in your Output Contract.
I think the problem is there.

Regards,

**Data action contract is **

{
"title": "Dynamodata",
"type": "object",
"properties": {
"date": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": true
}

**The mapping template from the database table extract is **
{
"TableName": "Customers",
"PrimaryKey": "customerid",
"KeyConditionExpression": "customerid = :v1",
"ExpressionAttributeValues": {
":v1": {
"S": "$input.params('customerid')"
}
}
}

The problem is in your translationMap.
I had missed that - didn't pay enough attention to your sample rawResult.

Given the example you have posted, the JSONPath expression you have defined: "name": "$..name"*
will return:

[
  {
    "S": "Jon Doe"
  }
]

Then, taking first element in the array ({"S": "John Doe"}) and trying to assign it to a string variable fails.

Your JSONPath expression should be: "name": "$..name.S"

Regards,

Awesome! Works. Really appreciate it.

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