首页 > 解决方案 > Powershell 捕获 curl 错误

问题描述

我有一个简单的 Powershell 函数来调用 Web api 并获得响应。如何确定 Web api 调用是成功还是失败。如果失败,我如何只记录失败的异常消息。我正在为 Windows 使用 curl。下面是我的 Powershell 脚本,

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
}

标签: javascriptwindowspowershellcurlasp.net-web-api

解决方案


推荐阅读