title: Powershell API request with cookies
body: <p>I am trying to make an API request in Powershell.</p>
  
  <p><strong>The curl command that works:</strong></p>
  
  <pre><code>curl -k -v -X GET -H "Cookie: customer=&lt;valueA&gt;;JSESSIONID=&lt;ValueB&gt;" -H "Accept: application/json" https://someurl.net/path/path
  </code></pre>
  
  <p>I Tried:</p>
  
  <pre><code>$session = New-Object Microsoft.Powershell.Commands.WebRequestSession
  $cookie = New-Object System.Net.Cookie
  $cookie2 = New-Object System.Net.Cookie
  
  $cookie.Name = "customer"
  $cookie.Value = "&lt;valueA&gt;"
  $cookie.Domain = "https://someurl.net"
  
  $cookie2.Name = "JSESSIONID"
  $cookie2.Value = "&lt;valueB&gt;"
  $cookie2.Domain = "https://someurl.net"
  
  $session.Cookies.Add($cookie, $cookie2);
  
  Invoke-WebRequest -Uri "https://someurl.net/path/path" -Method Get -WebSession $session -Headers  @{"accept"="application/json"}
  </code></pre>
  
  <p>This should return a json payload. Any help is appreciated.</p>