0

I am confused on a Jmeter variable not getting picked up by the CSV Data config. I have a Thread with HTTP request, CSV Data Config, HTTP Header Manager, and Results Tree. Everything seems to work fine, but there is just one variable that is not recognized...

Here is the Request Body after running the test:

{  
    "W_ID": "${W_ID}",  
    "b": "b",  
    "c": "c",  
    "d": "d"  
} 

For some reason the W_ID variable is not being recognized, but other variables are. All rows have the correct value assigned to them except the W_ID. I tried deleting the W_ID column from my file(in case there was weird formatting or white space), saving, and re-running the test, but same results.

Any ideas? Thanks for your help! Please let me know if I can provide more information or clarity.

Edit1: I noticed that the object name shows up in the body of the service... could that have an impact? This is the body (inv_adj is the object name):

{  
  "inv_adj": {  
    "W_ID": "string",  
    "a": "string",  
    "b": "string",  
    "c": "string",  
}

Edit2: CSV variables were requested:
Row 1: W_ID, b, c, d
Row 2: a, b, c, d

3
  • In the HTTP Request, here is the Body Data: { "i_adj": { "W_ID": "${W_ID}", "a": "${a}", "b": "${b}", "c": "${c}", Commented Mar 8, 2019 at 21:53
  • 1
    Please post the variable names that you have given in your CSV data set config. Commented Mar 8, 2019 at 23:14
  • CSV variables added. Commented Mar 11, 2019 at 15:24

2 Answers 2

1

In JMeter, If Variables are referenced as follows:

${VARIABLE}

If an undefined function or variable is referenced, JMeter does not report/log an error - the reference is returned unchanged. For example, if UNDEF is not defined as a variable, then the value of ${UNDEF} is ${UNDEF}.

So, Double check your CSV Data Set Config that how you have defined your variable name for each row. Is it WarehouseID or W_ID in your CSV data set config? If you use as WarehouseID in your CSV data set config, then you should use like {"W_ID": "${WarehouseID}"}in your HTTP Sampler's body.

Edit:

Here is an example step by step:

  1. CSV Data Set:

enter image description here

  1. CSV Data Set Config:

enter image description here

  1. Request Body Before Test:

enter image description here

  1. Request Body After Test in Results Tree:

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your reply. I made sure all of the variable names match within each area that they are declared. The CSV file has W_ID in Row A, Column 1. The HTTP request has "W_ID": "${W_ID}",
Could it have something to do with the object name being in the body? The body format has '{ "inv_adj": { "W_ID": "string", "a": "string", "b": "string", "c": "string" }'
Hi, I didn't find any problem with that. I've edited the answer with an example. Check it out if you have used like this or not. Thanks
The only thing that looks different is that you used Notepad and I used Excel. I still saved my file as .csv though, so I assume it is the same. Also your step 3 looks different than mine. I am using the HTTP Request... what did you use?
I've used Dummy Sampler for Debugging purpose. Are you facing it for only one variable? Did you check after changing your variable names? Did it occur every time (I mean after using .txt file)? I have also used .csv file and getting the expected result. Can you share your CSV Data Set Config? What did you mean Row2 for csv variables?
0

I tried to reproduce your issue locally on my JMeter instance. But I could not reproduce the error that you are facing. Unless we have your entire data file and the JMeter test plan, it is difficult to understand the issue. Please find below my test plan

CSV data set config

And then, look at the sampler configuration

enter image description here

When I replay this, I can see that the values are getting substituted properly.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.