Search code examples
javascriptpostmanguid

Postman $GUID: Remove hyphens and make all character uppercase


Can someone help me to remove the hyphens and transform all characters to uppercase (from a postman $guid)?

Haven't find anything useful.

Thanks


Solution

  • There are many hacky ways to do this in Postman, here's one of them:

    let guid = pm.variables.replaceIn('{{$guid}}')
    
    let formattedGuid = guid.replace(/-/g, '').toUpperCase()
    
    pm.globals.set("newGuid", formattedGuid)
    

    If you add that to the Pre-request Script, you'll be able to use it in the requests.