title: Netbox secrets with PowerShell
body: <p>I am trying to access secrets in Netbox like in this example</p>
  
  <p><a href="https://netbox.readthedocs.io/en/latest/api/working-with-secrets/" rel="nofollow noreferrer">https://netbox.readthedocs.io/en/latest/api/working-with-secrets/</a></p>
  
  <p>but using Powershell but I seem to have hit a brick wall. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>Add-Type -AssemblyName System.Web
  
  $Hdrs = @{}
  $Hdrs.Add("Authorization","Token fafcaea339cf926c0d79tokenf916aeec2d18bdd")
  $Hdrs.Add("Accept","application/json; indent=4")
  
  
  
  
  $body = Get-Content 'c:\key\private.txt'
  $body = [System.Web.HttpUtility]::UrlEncode($body) 
  
  
  
  Invoke-RestMethod -Method post -Uri "http://netbox.et/api/secrets/get-session-key/" -Headers $Hdrs -body $body
  </code></pre>
  
  <p>I just get the error</p>
  
  <pre><code>Invoke-RestMethod : Private key was not provided.
  </code></pre>
  
  <p>I'm pretty sure the issue is with how I am forming the request, however, I don't know enough about curl to know what '--data' do and how that would look in Powershell. Any help would be most appreciated. </p>