title: Conditionally sending jmeter variables with HTTP request
body: <p>I am using JMeter to send HTTP POST requests.</p>
  
  <p>My body of the request is JSON, for example something like <code>{"Var1": "${Var1}","Var2": ${Var2},"Var3":"${Var3}"}</code>.</p>
  
  <p>These are set in the parameters of the HTTP requests with no name for the parameter. This works fine and I am able to send requests using the variables that I set in a beanshell pre processor (by setting the variables and using vars.put() ).</p>
  
  <p>My question is how can I send programmatically through the preprocessor part of the parameters? For example:</p>
  
  <pre><code>if(a){
  send parameters `{"Var1": "${Var1}","Var2": ${Var2}` as my JSON
  }
  else {
  send parameters `{"Var3":"${Var3}"}` as my JSON
  }
  </code></pre>
  
  <p>vars.remove() doesn't work for me as it removes the value from the variable but still sends it in the request (for example as <code>"${Var1}"</code>).</p>