Forum Discussion

henil_shah's avatar
7 years ago

How to get Random String in Payload of a request

Just like we have ${=System.currentTimeMillis()} and ${=UUID.randomUUID()} for Timestamp and uuid, do we have any thing like this to get random String ? I dont want to create unnecessary Groovy step for this.



2 Replies

  • StevenColon's avatar
    SmartBear Alumni (Retired)

    Thank you for posting to our Community Forum. 


    You can utilize ${=<SCRIPT>} in the requests payload editor to input any script. 


    To generate a random string, use this script below:



    import org.apache.commons.lang.RandomStringUtils 
    charset = (('a'..'z') + ('A'..'Z') + ('0'..'9')).join()
    length = 9
    RandomStringUtils.random(length, charset.toCharArray())



     Let me know if you have any questions/concerns.