Home > Software design >  Getting blank response for $util methods in AWS API gateway
Getting blank response for $util methods in AWS API gateway

Time:12-16

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.

enter image description here

But I am getting a blank response for this code.

enter image description here

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
  • Related