Avnish Rathore
Avnish Rathore

Reputation: 99

How to encode any CSV data in JMETER and will use that as input parameter ${}

enter image description here

enter image description here How to encode input filed "fileData"(from CSV) and use it as input parameter like ${fileData}

below is the ex- fileData input should be converted like=

{"fileData":"QkVOLCxIb21lQmFuajc2MjkxNzI2MTcxOTU0MjI1OTQ5ODkxNjIzMjI0ODUyODI3NjI5MTcyNjE3MTk1NDIyNTk0OTg5MTYyMzIyNDg1MjgyQVZJMSwsSG9tZUJhbmtqNjI5MTcyNjE3MTk1NDIyNTk0OTg5MTYyMzIyNDg1MjgyNzYyOTE3MjYxNzE5NTQyMjU5NDk4OTE2MjMyMjQ4NVJFQ09SREEsLGFkZHJlc3MsLCwsLCwsLCwsLERTQVMyLCwsLCwsLCwsLCwsLCwsLCwsLFksLCwsLCwsLCwsLCwsLE4sLCwsLCwsLCwsLERTQVMyLCwsQ0=="

POST data: {"fileData":""${fileData}","fileName":"JMETER1.txt","fileDescription":"testing file upload with single data","isEncrypted":"N","encryptionDetails":{"algorithm":"","secretKey":"","signatureBytes":""},"valMode":"N"}

Upvotes: 0

Views: 755

Answers (1)

Dmitri T
Dmitri T

Reputation: 168122

You need to encode the data from your CSV file in Base64

There is __base64Encode() function which can do the trick for you:

enter image description here

Your request syntax should look like:

{
  "fileData": "${__base64Encode(${fileData},)}",
  "fileName": "JMETER1.txt",
  "fileDescription": "testingfileuploadwithsingledata",
  "isEncrypted": "N",
  "encryptionDetails": {
    "algorithm": "",
    "secretKey": "",
    "signatureBytes": ""
  },
  "valMode": "N"
}

enter image description here

and variable substitution will happen in the runtime:

enter image description here

You can install __base64Encode() function along with other Custom JMeter Functions using JMeter Plugins Manager

enter image description here

Upvotes: 1

Related Questions