title: Invoke webrequest -body containing variables
body: <p>Morning people of stackoverflow,</p>
  
  <p>I have an issue which google cant help me resolve.</p>
  
  <p>We have a API which we authenticate with using the following code:</p>
  
  <pre><code>$DeviceNumber = Read-Host "Enter device number"
  $URL= "https://URL.diskspace.website.com/v1/"
  $pass = 'password123'
  $postParam = '{"password":"$pass"}'
  $AuthToken = ""
  
  
  #Log in to the URL
  $IWRLogin = Invoke-WebRequest -Method Post -Uri $URL/login/$env:username -ContentType application/json -Body $postParam
  </code></pre>
  
  <p>This returns a Authentication code which is then parsed when using the API.</p>
  
  <p>However, the above does not work. For this to work I need to have my password hard coded, like the following:</p>
  
  <pre><code>$postParam = '{"password":"password123"}'
  </code></pre>
  
  <p>Ideally I want to have the user enter their password, it be stored and be used in the body of the invoke webrequest. Infact I would like to use the get-credentials feature of powershell because this will encrypt the password which is always good.</p>
  
  <p>Please help me out guys :)</p>
  
  <p>PS. Variables are random to hide sensitive information, if it doesn't make sense that is why..</p>