Forum Discussion

BrianFixzone's avatar
2 years ago
Solved

Encoding

Hi,  I have a test that is pulling data from an MSSQL query .. this is generally working well but have some records with values that cause errors when they are used within the json payload ... below...
  • nmrao's avatar
    2 years ago

    Here is some example to encode into base64:

     

    def data = "Hello, world!"
    def encodedData = data.bytes.encodeBase64().toString()
    log.info "Encoded data: $encodedData"
    

    if you want to use in your json payload, then there are multiple ways

    1. store the encoded value in a test case custom property and use that in json

    2. Use inline code in JSON such as "${= "Hello World".bytes.encodeBase64().toString()}"