ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

API Gateway: Generate UUID with 12 digits


Article ID: 223031


Updated On:


CA API Gateway


There's a requirement to generate a UUID with a length restriction of "12". The Generate UUID assertion produces a UUID that doesn't meet our requirement.
Using the "${gateway.random.[byte].[type]}" context variable to create a random number with the length restriction produces the below error. 
  • 2021-08-26T10:19:33.854-0400 SEVERE 17701 com.l7tech.server.SoapMessageProcessingServlet: Unable to select from com.l7tech.util.RandomByteGen
  • java.lang.IllegalStateException: Unable to select from com.l7tech.util.RandomByteGen

Is there a way to generate a UUID with 12 digits?


Gateway 9.X, 10.X


You can generate a 12-digit UUID/string with the following: ${gateway.random.6.hex}

NOTE: The context variable ${gateway.random.[byte].hex} will generate a UUID/string that is DOUBLE the number of specified bytes. For example, ${gateway.random.24.hex} will generate a 48-digit UUID/string.