Search code examples
filejmeterdecode

JMeter: How to decode alphanumeric characters fetched in JMETER response to its valid value?


I have a JMeter test plan which basically downloads a file by breaking it into multiple parts. However, these parts are received in encoded alphanumeric character format.

For instance, we have a .txt file which is broken down into 2 parts. Each part has an encoded set of characters. I have been successful so far in appending these characters into another file. Is there a way of restoring the contents of this file ( holding alphanumeric characters) into the original .txt file with its valid contents back again?

e.g. JMeter response: <data> aWJiZWFuLFBhbmFtYSxDb3NtZXRpY </data>

Can someone please suggest the steps to achieve this?


Solution

  • It looks like it is Base64-encoded, you can use __base64Decode() function (can be installed as a part of Custom JMeter Functions bundle using JMeter Plugins Manager)

    ${__base64Decode(aWJiZWFuLFBhbmFtYSxDb3NtZXRpY,)}
    

    enter image description here

    If you don't have possibility or unwilling to use JMeter Plugins you can achieve the same using JMeter's built-in __groovy() function:

    ${__groovy(new String('aWJiZWFuLFBhbmFtYSxDb3NtZXRpY'.decodeBase64()),)}
    

    enter image description here