title: Making a PowerShell invoke-restmethod request
body: <p>I have been challenged to get a response from an api with powershell.</p>
  <p>I have little to no experience with powershell, but have at least been able to get a response from the API provider, but not a response i can use, so i hope someone can help me.
  The photo is of the documentaion i have
  <a href="https://i.stack.imgur.com/rAd61.png" rel="nofollow noreferrer">Documentation</a></p>
  <p>What i can't figure out is how i send the message that i want a response for.
  The command is the specific api that i need to use, and it has some inputs as seen in the photo.</p>
  <p>Input to API:
  StreetName
  BuildingIdentifier
  Floor
  Suite
  DistrictCode</p>
  <p>This is what i got so far.</p>
  <pre><code>$uri = 'SomeUrl.com'
  $command = '/Ois/RealUnit/Address'
  $token = 'SomeSecureToken'
  $contentType = 'application/json'
  $secureToken = ConvertTo-SecureString $token -AsPlainText -force
  
  
  $webResult = Invoke-RestMethod -Method get -Uri $uri -ContentType $contentType -Token $secureToken
  write-output $webResult
  </code></pre>
  <p>What i know but i don't know how to use or i it has to be used is as follows.</p>
  <ul>
  <li>Request URL: <a href="https://SomeUrl.com/Ois/RealUnit/Address" rel="nofollow noreferrer">https://SomeUrl.com/Ois/RealUnit/Address</a></li>
  <li>Response body: is JSON and i only need the response for &quot;unitUse&quot;</li>
  <li>Response Code: I also know that a good response gives the code 200</li>
  <li>Curl: I also know that something called CURL looks a bit like this <code>curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'StreetName=STREET&amp;BuildingIdentifier=123&amp;Floor=12&amp;Suite=th&amp;DistrictCode=1234' 'https://SomeUrl.com/Ois/RealUnit/Address'</code></li>
  <li>Reponse Header: Looks like this
  <code>{ &quot;access-control-allow-headers&quot;: &quot;Content-Type&quot;, &quot;access-control-allow-methods&quot;: &quot;GET, POST, PUT, DELETE, PATCH, OPTIONS&quot;, &quot;access-control-allow-origin&quot;: &quot;*&quot;, &quot;cache-control&quot;: &quot;private&quot;, &quot;content-length&quot;: &quot;7604&quot;, &quot;content-type&quot;: &quot;application/json; charset=utf-8&quot;, &quot;date&quot;: &quot;Tue, 08 Mar 2022 13:21:27 GMT&quot;, &quot;server&quot;: &quot;Microsoft-IIS/8.5&quot;, &quot;strict-transport-security&quot;: &quot;max-age=31536000&quot;, &quot;vary&quot;: &quot;Accept&quot;, &quot;x-aspnet-version&quot;: &quot;4.0.30319&quot;, &quot;x-powered-by&quot;: &quot;ServiceStack/5.10 NET45 Win32NT/.NET, ASP.NET&quot; }</code></li>
  </ul>