I am aiming to send following format to the data:
{
"headers": {
"Authorization": "Bearer expectedToken"
},
"body": {
"id": "abc",
"status": "ANY",
"preferences": [ [Object] ]
}
}
but struggling with the Input transformer in YAML:
inputTransformer:
inputPathsMap:
expectedToken: '$detail.metadata.someToken'
inputTemplate: '{"headers": {"Authorization": <expectedToken>}}'
And getting this error:
Received response status [FAILED] from custom resource. Message returned: Event pattern is not valid. Reason: "expectedToken" must be an object or an array+ +at [Source: (String)"{"inputTransformer":{"inputPathsMap":{"expectedToken":"$detail.metadata.someToken"},"inputTemplate":"{"headers": {"Authorization": }}"},"
Trigger is an APIGW with a mapping template that appends a Auth token as part of the metadata, but the target expects it as a header. Is it a viable solution? How can this be resolved to the expected format?
Later Edit: Data being sent from APIGW:
{
detail: {
body: {
id: 'abc',
extraInfo: 'Postman_15:07',
preferences: [Array]
},
metadata: {
service: 'my-service',
status: 'ANY',
someToken: 'Bearer expectedToken'
}
}
}