Google Chrome allows you to copy an executed xhr request and replay it in PowerShell:
- Open the developer tools (F12)
Open the network tab
Trigger the netwerk request by executing the functionality in you web application
Right click the request in the network tab, then “Copy” and then “Copy as PowerShell”
Now paste this in a PowerShell prompt and you should get the same result as in the browser.
If the request returns an exception (http error code), then you can use the following code to get more information on the error:
Just replace the text “<< paste request from google Chrome here >>” with the copied xhr request.
$webResponse = << paste request from google Chrome here >>
Write-Host “Response: $($webResponse)”
Write-Host “ErrorDetails: $($_.ErrorDetails)”
Write-Host “ExceptionResponse: $($_.Exception.Response)”
p style=”background: #1e1e1e”>}