当我尝试在windows powershell 中运行此代码时
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://videointelligence.googleapis.com/v1/videos:annotate" | Select-Object -Expand Content
我收到这个错误:
术语";调用WebRequest";未识别
InvokeWebRequest已添加到powershell 3.0 中
所以你的powershell比较老Windows 7附带2.0版本(如果是这样的话(
您可以通过安装WMF 5.1:https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/wmf/setup/install-configure
如果无法更新,则必须使用Net Framework的类来处理web请求:https://learn.microsoft.com/en-us/dotnet/api/system.net.webrequest