0
votes

I am using CSV Data set config to send different json request to server using __FileToString function. Everything works fine but when this function reads the .json file and put into body then it adds some extra line " # JMeter generated Header file" into json payload for which i am getting below response.

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">
  <error>
    <error-tag>malformed-message</error-tag>
    <error-urlpath>/api/running</error-urlpath>
    <error-message>Bad JSON character: #</error-message>
  </error>
</errors>
Function call
=============
${__FileToString(C:/Users/chandans/Desktop/apache-jmeter-5.0/apache-jmeter-5.0/bin/${__eval(${JSON_FILE})}.txt,,)}

Can anyone help me how to remove this line "# JMeter generated Header file" from json payload before sending the request to the server??

1

1 Answers

0
votes

You don't need to use __eval() function in this case. Also, the path can be relative to the JMeter launch directory. So, try to use

${__FileToString(${JSON_FILE}.txt,,)}

instead of

${__FileToString(C:/Users/chandans/Desktop/apache-jmeter-5.0/apache-jmeter-5.0/bin/${__eval(${JSON_FILE})}.txt,,)}

Check this Test Plan with __FileToString() function as an example.