API Gateway: Generate UUID with 12 digits
search cancel

API Gateway: Generate UUID with 12 digits

book

Article ID: 223031

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

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. 
 
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?

Environment

Gateway 9.X, 10.X

Resolution

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.