I recently modified source code to enable me to insert variables into post data quite easily actually. In HTTPSampler when sending post data and iterating through the GUI arguments just changed the code to look something like this: while (args.hasNext()) { HTTPArgument arg = (HTTPArgument) args.next().getObjectValue(); int left = arg.getValue().indexOf("{"); int right = arg.getValue().indexOf("}", left); String val = arg.getValue(); if ((left != -1) && (right != -1)) { // we may have a variable String varName = arg.getValue().substring(left + 1, right); val = JMeterContextService.getContext().getVariables().get(varName); // this variable isn't defined or this wasn't actually a variable if (val == null) val = arg.getValue(); } parts[partNo++] = new StringPart(arg.getName(), val, contentEncoding); } This allows for a variable defined by JMeter to be inserted, particularly useful for multiple threads needing different values in a URL and if the variable doesn't exist it just keeps the value in.
Variable substitution already works for POST arguments in JMeter 2.3. If it is not working for you, please attach a test case to this issue.
I am using JMeter 2.5.1 and using the 'Random Variable' - the variable substitution does not work for POST data. I did: 1. Create a random variable 'myVar' 2. Created a http request - method POST 3. Added a file in the 'Send Files With the Request' (Note: 'Use multipart/form-data...' is un checked) 4. Used the above created random variable place holder ${myVar} in the file added above step Tried with JMeter 2.3.4 version which also did not work.
(In reply to comment #2) > I am using JMeter 2.5.1 and using the 'Random Variable' - the variable > substitution does not work for POST data. > I did: > 1. Create a random variable 'myVar' > 2. Created a http request - method POST > 3. Added a file in the 'Send Files With the Request' (Note: 'Use > multipart/form-data...' is un checked) > 4. Used the above created random variable place holder ${myVar} in the file > added above step JMeter has never supported variable substitution in external files, only in fields on the Gui screen. > Tried with JMeter 2.3.4 version which also did not work.
See BUG 15468 to check that you're in the same scenario. I think it's a duplicate.
*** This bug has been marked as a duplicate of bug 15468 ***
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2045