I am trying to use the Mock integration to just "echo" back me the JSON body that I sent. However, I just can't get it to work. I can return any arbitrary JSON body from my "POST - Integration Response", but the request JSON is never found via $input.json('$')
. I have been able to successfully echo back any query parameters.
My API has a single "/" path and a single method defined (POST). The exported yaml is here .
Any idea as to what may be going on?
I've found this to actually be possible, although a little hacky. First, in the integration request mapping template you store the body in a path parameter.
#set($context.requestOverride.path.body = $input.body)
{
"statusCode": 200,
}
Then in the integration response mapping template you fetch it back and return it.
#set($body = $context.requestOverride.path.body)
{
"statusCode": 200,
"body": $body,
}
This seems to even work well with larger payloads.
Unfortunately this is not supported. In the mapping template for "Integration Response", $input
represents the payload received from the integration response (which is empty in the case of a MOCK
integration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With