Prasad Lele
Prasad Lele

Reputation: 354

Getting blank response for $util methods in AWS API gateway

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.

Upvotes: 0

Views: 878

Answers (2)

Shawn
Shawn

Reputation: 9402

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 directly without it coming from the input somehow (like context or parameters).

Upvotes: 1

Prasad Lele
Prasad Lele

Reputation: 354

I generated UUID from request-id

$context.requestId

Upvotes: 2

Related Questions