title: Rename Query Parameter in Outbound Request in Azure API Management
body: <p>Using policies in Azure API Management, I'm trying to rename a query parameter, but it does not work.  If I change copy-unmatched-params="false" to copy-unmatched-params="true" then it works, but the behaviour becomes that all unmatched parameters will get passed to the backend API which would allow clients to inject their own query params into the backend request which we do not want.</p>
  
  <p>Everything else is fine.  </p>
  
  <p>I want to transform a request that comes in that looks like this:</p>
  
  <pre><code>https://{site}/search?query=dylan
  </code></pre>
  
  <p>To:</p>
  
  <pre><code>https://{backend-site}documents?api-version=2018-1-11&amp;amount=1000&amp;searchFields=Album,Artist&amp;search=dylan
  </code></pre>
  
  <p>The only part that doesn't work is transforming the query parameter to be named "search" instead of query without allowing all parameters to be passed on from the inbound querystring.   How can I fix that?</p>
  
  <pre><code>&lt;policies&gt;
      &lt;inbound&gt;
          &lt;rewrite-uri template="/" copy-unmatched-params="false" /&gt;
          &lt;set-header name="api-key" exists-action="override"&gt;
              &lt;value&gt;THIS-IS-API-KEI&lt;/value&gt;
          &lt;/set-header&gt;
          &lt;set-query-parameter name="api-version" exists-action="override"&gt;
              &lt;value&gt;2018-1-11&lt;/value&gt;
          &lt;/set-query-parameter&gt;
          &lt;set-query-parameter name="amount" exists-action="override"&gt;
              &lt;value&gt;1000&lt;/value&gt;
          &lt;/set-query-parameter&gt;
          &lt;set-query-parameter name="searchFields" exists-action="override"&gt;
              &lt;value&gt;Album,Artist&lt;/value&gt;
          &lt;/set-query-parameter&gt;
          &lt;set-query-parameter name="search" exists-action="override"&gt;
              &lt;value&gt;@(context.Request.Url.Query.GetValueOrDefault("query"))&lt;/value&gt;
          &lt;/set-query-parameter&gt;
      &lt;/inbound&gt;
      &lt;backend&gt;
          &lt;base /&gt;
      &lt;/backend&gt;
      &lt;outbound&gt;
          &lt;base /&gt;
      &lt;/outbound&gt;
      &lt;on-error&gt;
          &lt;base /&gt;
      &lt;/on-error&gt;
  &lt;/policies&gt;
  </code></pre>