Powershell catch curl errors

  asp.net-web-api, curl, javascript, powershell, windows

I have a simple Powershell function to call a web api and get a response. How to find out if the web api call succeeded or failed. If failed how can i log only the failed exception message. I am using curl for windows.
Below is my Powershell script,

function PowershellCore_CurlFunction()
{
    $curlResponse = curl -s  "$url"
    # How to check if web api call is succeeded or failed
    # How to log error if web api call throws exception
}

Source: Windows Questions

LEAVE A COMMENT