title: Invoke-RestMethod converts backslash to slash
body: <p>I would like to call a REST API passing a parameter that contains a backslash character.</p>
  
  <p>The API expects a route like <code>api/test/&lt;app_name&gt;/&lt;user_name&gt;</code>, and for example I would like to pass <code>domain\login</code> as value for <code>user_name</code>.</p>
  
  <p>I tried this with PowerShell:</p>
  
  <pre><code>$uri = [Uri]::EscapeUriString("http://localhost:5555/api/test/App Name/Domain\login")
  # now $uri = 'http://localhost:5555/api/test/App%20Name/Domain%5Clogin'
  Invoke-RestMethod -Method Get -Uri $uri -Verbose
  </code></pre>
  
  <p>The output of <code>Invoke-RestMethod</code> with the <code>-Verbose</code> flag shows that PowerShell <strong>is converting the backslash to a slash</strong>, and after that I get a 404 from the REST API (which is expected since the route does not match):</p>
  
  <pre><code>VERBOSE: GET http://localhost:5555/api/test/App Name/Domain/login with 0-byte payload
  Invoke-RestMethod :
  404 Not Found
  </code></pre>
  
  <p><strong>How can I avoid this behavior and use a path with an encoded backslash?</strong></p>
  
  <p>Here is the output of my <code>$PSVersionTable</code> variable:</p>
  
  <pre><code>&gt; $PSVersionTable
  
  Name                           Value
  ----                           -----
  PSVersion                      5.1.14393.953
  PSEdition                      Desktop
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
  BuildVersion                   10.0.14393.953
  CLRVersion                     4.0.30319.42000
  WSManStackVersion              3.0
  PSRemotingProtocolVersion      2.3
  SerializationVersion           1.1.0.1
  </code></pre>