I am trying to generate a UUID for mocking purposes in the AWS API gateway.
#set($myValue = "$util.autoId()")
##Prints '5'
$myValue
{"abc" : "$myValue"}
Here is a snapshot of the integration response.
But I am getting a blank response for this code.
Same issue with all other $util functions.
How to generate random UUID without using lambda.
CodePudding user response:
It looks like you may be trying to use an option that is available for mappings with AppSync. $util.autoId
is available there: https://docs.aws.amazon.com/appsync/latest/devguide/resolver-util-reference.html
But for API Gateway, the $util
options are different: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#util-template-reference
So autoId
isn't an available option, and none of the other API Gateway variables and functions look like they'll get you a UUID without it coming from the input somehow.
CodePudding user response:
I generated UUID from request-id
$context.requestId