Ask a Question

Encoding

SOLVED
BrianFixzone
Member

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 is the very simplified version of the usage.   Is there a way to json encode the data ?

 

{

  "repfault"  : "${Data Source#repfault}"

}

1 REPLY 1
nmrao
Community Hero

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()}"



Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: