Powershell Generic Invoke-RestMethod / WebRequest error handler

From: https://stackoverflow.com/questions/39319680/onelogin-rest-api-with-powershells-invoke-restmethod

Then, wrap all of your Invoke-RestMethod calls in a try Catch block like this.

Now when you run into an error, you can see the actual message, like this

Windows PowerShell concatenate and escape multi-line string

$x = @"
"Curiouser and curiouser!" cried Alice (she was so much surprised, that for the moment she quite forgot how to speak good English); "now I'm opening out like the largest telescope that ever was! Good-bye, feet!"
"@
$x

Source: Windows PowerShell Tip: Using Windows PowerShell “Here-Strings”