I'm using Powershell v4.
I am calling a POST API and want to see the response when I run Invoke-RestMethod
but it just shows a new line.
How can I output the response from the API to the console? I have tried running it in a script with Write-Host
and Write-Output
, but nothing appears on the console screen.
PowerShell script:
$Response = Invoke-RestMethod -Uri https://localhost:8081/myAPI -Body '{"username":"xyz","password":"xyz"}' -ContentType application/json -Method POST
Write-Host $Response
I can see the response when I curl
the API but cannot see it in my PowerShell script which I need to use.
CURL
curl -H "Content-Type: application/json" -X POST -d '{"username":"xyz","password":"xyz"}' https://localhost:8081/myAPI
It looks like its not even hitting the API as nothing appears in the API logs when triggering from Powershell. Not sure how to resolve that if that is the problem.