title: JMeter Removes forward slash from start of path parameter
body: <p>I have an endpoint which looks like the following: <code>www.example.com/example/{resource}</code>. The resource parameter is normally a uri looking string like this: <code>/resource/123</code> which is encoded like this: %2Fresource%2Fid%2F123. The starting forward slash is important, the endpoint does a direct match on something in a database, so it is important.</p>
  
  <p>The issue I am facing is that somewhere between JMeter and the endpoint, the starting forward slash is removed. I tried running the app which has the endpoint locally and when I make the request from PostMan, like this: <code>GET www.example.com/example/%2Fresource%2F123</code>, the endpoint decodes it correctly. </p>
  
  <p>In JMeter, I load the resources from a CSV file, which looks like this: </p>
  
  <pre><code>resource
  /resource/123
  /resource/456
  /resource/789
  </code></pre>
  
  <p>And in my HTTP Request Config, I use resource like this: <code>/example/${__urlencode(${resource})}</code>. The urlencode function doesn't seem to make any different either way.</p>
  
  <p>Whatever I do, when the request is made from JMeter, it doesn't work as expected because the starting hash in resource is removed. I know I could change the endpoint to add a hash if there isn't one but I don't want to change the functionality of the endpoint specifically for JMeter testing. </p>
  
  <p>Any ideas?</p>
  
  <h2>Edit 1</h2>
  
  <p>Here is the csv options: </p>
  
  <pre><code>&lt;CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="Resource Ids" enabled="true"&gt;
     &lt;stringProp name="delimiter"&gt;,&lt;/stringProp&gt;
     &lt;stringProp name="fileEncoding"&gt;&lt;/stringProp&gt;
     &lt;stringProp name="filename"&gt;data/resource.csv&lt;/stringProp&gt;
     &lt;boolProp name="ignoreFirstLine"&gt;true&lt;/boolProp&gt;
     &lt;boolProp name="quotedData"&gt;false&lt;/boolProp&gt;
     &lt;boolProp name="recycle"&gt;true&lt;/boolProp&gt;
     &lt;stringProp name="shareMode"&gt;shareMode.group&lt;/stringProp&gt;
     &lt;boolProp name="stopThread"&gt;false&lt;/boolProp&gt;
     &lt;stringProp name="variableNames"&gt;resource&lt;/stringProp&gt;
  &lt;/CSVDataSet&gt;
  </code></pre>
  
  <p>Here is the HTML Request Config: </p>
  
  <pre><code>&lt;HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="API Request" enabled="true"&gt;
      &lt;elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"&gt;
        &lt;collectionProp name="Arguments.arguments"/&gt;
      &lt;/elementProp&gt;
      &lt;stringProp name="HTTPSampler.domain"&gt;localhost&lt;/stringProp&gt;
      &lt;stringProp name="HTTPSampler.port"&gt;8303&lt;/stringProp&gt;
      &lt;stringProp name="HTTPSampler.protocol"&gt;http&lt;/stringProp&gt;
      &lt;stringProp name="HTTPSampler.contentEncoding"&gt;&lt;/stringProp&gt;
      &lt;stringProp name="HTTPSampler.path"&gt;/example/${__urlencode(${resource})}&lt;/stringProp&gt;
      &lt;stringProp name="HTTPSampler.method"&gt;GET&lt;/stringProp&gt;
      &lt;boolProp name="HTTPSampler.follow_redirects"&gt;true&lt;/boolProp&gt;
      &lt;boolProp name="HTTPSampler.auto_redirects"&gt;false&lt;/boolProp&gt;
      &lt;boolProp name="HTTPSampler.use_keepalive"&gt;true&lt;/boolProp&gt;
      &lt;boolProp name="HTTPSampler.DO_MULTIPART_POST"&gt;false&lt;/boolProp&gt;
      &lt;stringProp name="HTTPSampler.embedded_url_re"&gt;&lt;/stringProp&gt;
      &lt;stringProp name="HTTPSampler.connect_timeout"&gt;&lt;/stringProp&gt;
      &lt;stringProp name="HTTPSampler.response_timeout"&gt;&lt;/stringProp&gt;
  &lt;/HTTPSamplerProxy&gt;
  </code></pre>
  
  <h2>Edit 2</h2>
  
  <p>I have added this pre-processor: </p>
  
  <pre><code>&lt;JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor" enabled="true"&gt;
    &lt;stringProp name="cacheKey"&gt;true&lt;/stringProp&gt;
    &lt;stringProp name="filename"&gt;&lt;/stringProp&gt;
    &lt;stringProp name="parameters"&gt;&lt;/stringProp&gt;
    &lt;stringProp name="script"&gt;vars.put(&amp;quot;resource&amp;quot;, URLEncoder.encode(vars.get(&amp;quot;resource&amp;quot;), &amp;quot;UTF-8&amp;quot;)); &lt;/stringProp&gt;
    &lt;stringProp name="scriptLanguage"&gt;groovy&lt;/stringProp&gt;
  &lt;/JSR223PreProcessor&gt;
  </code></pre>
  
  <h2>Edit 3</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137"&gt;
    &lt;hashTree&gt;
      &lt;TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true"&gt;
        &lt;stringProp name="TestPlan.comments"&gt;&lt;/stringProp&gt;
        &lt;boolProp name="TestPlan.functional_mode"&gt;false&lt;/boolProp&gt;
        &lt;boolProp name="TestPlan.tearDown_on_shutdown"&gt;true&lt;/boolProp&gt;
        &lt;boolProp name="TestPlan.serialize_threadgroups"&gt;false&lt;/boolProp&gt;
        &lt;elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"&gt;
          &lt;collectionProp name="Arguments.arguments"/&gt;
        &lt;/elementProp&gt;
        &lt;stringProp name="TestPlan.user_define_classpath"&gt;&lt;/stringProp&gt;
      &lt;/TestPlan&gt;
      &lt;hashTree&gt;
        &lt;ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group - Test API" enabled="true"&gt;
          &lt;stringProp name="ThreadGroup.on_sample_error"&gt;continue&lt;/stringProp&gt;
          &lt;elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true"&gt;
            &lt;boolProp name="LoopController.continue_forever"&gt;false&lt;/boolProp&gt;
            &lt;stringProp name="LoopController.loops"&gt;2&lt;/stringProp&gt;
          &lt;/elementProp&gt;
          &lt;stringProp name="ThreadGroup.num_threads"&gt;1&lt;/stringProp&gt;
          &lt;stringProp name="ThreadGroup.ramp_time"&gt;0&lt;/stringProp&gt;
          &lt;boolProp name="ThreadGroup.scheduler"&gt;false&lt;/boolProp&gt;
          &lt;stringProp name="ThreadGroup.duration"&gt;3600&lt;/stringProp&gt;
          &lt;stringProp name="ThreadGroup.delay"&gt;3600&lt;/stringProp&gt;
        &lt;/ThreadGroup&gt;
        &lt;hashTree&gt;
          &lt;GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="Get List Items" enabled="true"/&gt;
          &lt;hashTree&gt;
            &lt;CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="Resource Ids" enabled="true"&gt;
              &lt;stringProp name="delimiter"&gt;,&lt;/stringProp&gt;
              &lt;stringProp name="fileEncoding"&gt;&lt;/stringProp&gt;
              &lt;stringProp name="filename"&gt;data/resource.csv&lt;/stringProp&gt;
              &lt;boolProp name="ignoreFirstLine"&gt;true&lt;/boolProp&gt;
              &lt;boolProp name="quotedData"&gt;false&lt;/boolProp&gt;
              &lt;boolProp name="recycle"&gt;true&lt;/boolProp&gt;
              &lt;stringProp name="shareMode"&gt;shareMode.group&lt;/stringProp&gt;
              &lt;boolProp name="stopThread"&gt;false&lt;/boolProp&gt;
              &lt;stringProp name="variableNames"&gt;resource&lt;/stringProp&gt;
            &lt;/CSVDataSet&gt;
            &lt;hashTree/&gt;
            &lt;HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Example API Request" enabled="true"&gt;
              &lt;elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"&gt;
                &lt;collectionProp name="Arguments.arguments"/&gt;
              &lt;/elementProp&gt;
              &lt;stringProp name="HTTPSampler.domain"&gt;localhost&lt;/stringProp&gt;
              &lt;stringProp name="HTTPSampler.port"&gt;8303&lt;/stringProp&gt;
              &lt;stringProp name="HTTPSampler.protocol"&gt;http&lt;/stringProp&gt;
              &lt;stringProp name="HTTPSampler.contentEncoding"&gt;&lt;/stringProp&gt;
              &lt;stringProp name="HTTPSampler.path"&gt;/example/${resourceId}&lt;/stringProp&gt;
              &lt;stringProp name="HTTPSampler.method"&gt;GET&lt;/stringProp&gt;
              &lt;boolProp name="HTTPSampler.follow_redirects"&gt;true&lt;/boolProp&gt;
              &lt;boolProp name="HTTPSampler.auto_redirects"&gt;false&lt;/boolProp&gt;
              &lt;boolProp name="HTTPSampler.use_keepalive"&gt;true&lt;/boolProp&gt;
              &lt;boolProp name="HTTPSampler.DO_MULTIPART_POST"&gt;false&lt;/boolProp&gt;
              &lt;stringProp name="HTTPSampler.embedded_url_re"&gt;&lt;/stringProp&gt;
              &lt;stringProp name="HTTPSampler.connect_timeout"&gt;&lt;/stringProp&gt;
              &lt;stringProp name="HTTPSampler.response_timeout"&gt;&lt;/stringProp&gt;
            &lt;/HTTPSamplerProxy&gt;
            &lt;hashTree&gt;
              &lt;JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor" enabled="true"&gt;
                &lt;stringProp name="cacheKey"&gt;true&lt;/stringProp&gt;
                &lt;stringProp name="filename"&gt;&lt;/stringProp&gt;
                &lt;stringProp name="parameters"&gt;&lt;/stringProp&gt;
                &lt;stringProp name="script"&gt;vars.put(&amp;quot;resource&amp;quot;, URLEncoder.encode(vars.get(&amp;quot;resource&amp;quot;), &amp;quot;UTF-8&amp;quot;)); &lt;/stringProp&gt;
                &lt;stringProp name="scriptLanguage"&gt;groovy&lt;/stringProp&gt;
              &lt;/JSR223PreProcessor&gt;
              &lt;hashTree/&gt;
            &lt;/hashTree&gt;
            &lt;ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true"&gt;
              &lt;collectionProp name="Asserion.test_strings"&gt;
                &lt;stringProp name="49586"&gt;200&lt;/stringProp&gt;
              &lt;/collectionProp&gt;
              &lt;stringProp name="Assertion.custom_message"&gt;&lt;/stringProp&gt;
              &lt;stringProp name="Assertion.test_field"&gt;Assertion.response_code&lt;/stringProp&gt;
              &lt;boolProp name="Assertion.assume_success"&gt;false&lt;/boolProp&gt;
              &lt;intProp name="Assertion.test_type"&gt;8&lt;/intProp&gt;
            &lt;/ResponseAssertion&gt;
            &lt;hashTree/&gt;
          &lt;/hashTree&gt;
        &lt;/hashTree&gt;
      &lt;/hashTree&gt;
    &lt;/hashTree&gt;
  &lt;/jmeterTestPlan&gt;
  </code></pre>