title: How to disable the URL encoding in the JSR 223 sampler for HTTP Request
body: <p>I am trying to automate the upload operation for my application using JSR223 Sampler with the following groovy script. But the <code>?</code> in that URI path is getting encoded and I am getting <code>http-404</code> error.</p>
  <p>Code Block:</p>
  <pre><code>import org.apache.http.HttpHeaders;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.client.utils.URIBuilder;
  import org.apache.http.client.config.RequestConfig;
  import org.apache.http.client.methods.HttpUriRequest;
  import org.apache.http.client.methods.RequestBuilder;
  import org.apache.http.message.BasicHeader;
  import org.apache.http.entity.ContentType;
  import org.apache.http.entity.mime.HttpMultipartMode;
  import org.apache.http.entity.mime.MultipartEntityBuilder;
  import org.apache.http.entity.InputStreamEntity;
  import org.apache.http.impl.client.HttpClients;
  import org.apache.http.impl.client.HttpClientBuilder;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.util.EntityUtils;
  import org.apache.http.conn.ssl.NoopHostnameVerifier;
  import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
  import org.apache.http.conn.ssl.TrustStrategy;
  import org.apache.http.entity.StringEntity;
  import org.apache.http.ssl.SSLContextBuilder;
  import java.security.cert.CertificateException;
  import java.security.cert.X509Certificate;
  
  def storageProtocol = &quot;https&quot;;
  def storageServer = &quot;localhost&quot;;
  def namespace = &quot;7c762733-009f-4527-81ea-571d1cf6e9d2&quot;
  def studyUid = &quot;1.2.300.0.7230010.3.1.2.2595064201.8112.1216202112026121&quot;;
  def imageUid = &quot;1.2.840.113704.7.1.0.1356918323635126.1521373008.110&quot;
  
  def RequestConfig uploadRequestConfig = RequestConfig.custom()
              .setConnectTimeout(30000)
              .setSocketTimeout(30000)
              .build();
  def uploadUriBuilder = new URIBuilder().setScheme(storageProtocol)
              .setHost(storageServer);
  
  def URI uri = uploadUriBuilder.setPath(&quot;/api/v3/storage/namespace/&quot; + namespace + &quot;/image?sid=&quot;+&quot;${SIDVALUE}&quot;)
              .setParameter(&quot;study_uid&quot;, studyUid)
              .setParameter(&quot;image_uid&quot;, imageUid)
              .build();
  
  def  RequestBuilder requestBuilder = RequestBuilder.create(&quot;POST&quot;)
          .setConfig(uploadRequestConfig)
          .setUri(uri)
          .setHeader(&quot;X-AmbraHealth-SID&quot;, &quot;${SIDVALUE}&quot;)
          .setHeader(&quot;X-Requested-With&quot;, &quot;XMLHttpRequest&quot;)
          .setHeader(&quot;X-DicomGrid-Client&quot;, &quot;USER&quot;)
          .setHeader(&quot;X-DicomGrid-Version&quot;, &quot;3.22.3.0&quot;)
          .setHeader(&quot;X-File-Name&quot;, &quot;IMG00001.dcm&quot;)
          .setHeader(&quot;Referer&quot;, &quot;https://${BASE_URL_1}/load.html?namespace_id=7c762733-009f-4527-81ea-571d1cf6e9d2&quot;)
          .setHeader(HttpHeaders.CONTENT_TYPE, &quot;application/dicom&quot;);
  
  def InputStreamEntity entity = new InputStreamEntity(new FileInputStream(&quot;C://Users//IMAGES//IMG00001.dcm&quot;));
  requestBuilder.setEntity(entity);
  
  def sslBuilder = new SSLContextBuilder();
  sslBuilder.loadTrustMaterial(null, new TrustStrategy(){
      @Override
      public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
          return true;
          }
      });
  
  
  def trustAllFactory = new SSLConnectionSocketFactory(sslBuilder.build(), new NoopHostnameVerifier());
  
  HttpClients.custom().setSSLSocketFactory(trustAllFactory).build().withCloseable { httpClient -&gt;
          httpClient.execute(requestBuilder.build()).withCloseable { response -&gt; {
                  def resp = EntityUtils.toString(response.getEntity());
              }
          }
      }
  </code></pre>
  <p>Request URL generating from the script:</p>
  <pre><code>https://localhost/api/v3/storage/namespace/7c762733-009f-4527-81ea-571d1cf6e9d2/image%3Fsid=fdbfbf07-bf4b-4ec5-b3cb-6e4353163f14?study_uid=1.2.300.0.7230010.3.1.2.2595064201.8112.1216202112026121&amp;image_uid=1.2.840.113704.7.1.0.1356918323635126.1521373008.110
  </code></pre>
  <p>There are two errors, <code>/image%3Fsid</code> should be <code>/image?sid</code> &amp; <code>*-6e4353163f14?study_uid=</code> should be <code>*-6e4353163f14&amp;study_uid=</code></p>
  <p>Working URL :</p>
  <pre><code>https://localhost/api/v3/storage/namespace/7c762733-009f-4527-81ea-571d1cf6e9d2/image?sid=fdbfbf07-bf4b-4ec5-b3cb-6e4353163f14&amp;study_uid=1.2.300.0.7230010.3.1.2.2595064201.8112.1216202112026121&amp;image_uid=1.2.840.113704.7.1.0.1356918323635126.1521373008.110
  </code></pre>
  <p>Error Details:</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot;/&gt;
  &lt;title&gt;Error 404 Not Found&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;&lt;h2&gt;HTTP ERROR 404 Not Found&lt;/h2&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;th&gt;URI:&lt;/th&gt;&lt;td&gt;/api/v2/namespace/7c762733-009f-4527-81ea-571d1cf6e9d2/image%3Fsid=fdbfbf07-bf4b-4ec5-b3cb-6e4353163f14&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th&gt;STATUS:&lt;/th&gt;&lt;td&gt;404&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th&gt;MESSAGE:&lt;/th&gt;&lt;td&gt;Not Found&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th&gt;SERVLET:&lt;/th&gt;&lt;td&gt;webservice&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;hr&gt;&lt;a href=&quot;https://eclipse.org/jetty&quot;&gt;Powered by Jetty:// 9.4.43.v20210629&lt;/a&gt;&lt;hr/&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>How to handle this encoding?</p>