首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell中的IBM Watson视觉识别

Powershell中的IBM Watson视觉识别
EN

Stack Overflow用户
提问于 2018-03-21 21:23:07
回答 1查看 239关注 0票数 0

我正在尝试将沃森视觉识别集成到一个powershell脚本中,我已经设置了我的免费帐户,并且一切都在码头容器中工作。但我一辈子都想不出如何让它在Powershell上工作。

示例curl命令是

代码语言:javascript
复制
curl "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classify?api_key={api-key}&url=https://watson-developer-cloud.github.io/doc-tutorial-downloads/visual-recognition/fruitbowl.jpg&version=2016-05-20"

其中{api-key}被替换为实际的api键。

因为这只是点击了一个URL,我想我应该可以使用

代码语言:javascript
复制
Invoke-RestMethod -Uri "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classify?api_key={api-key}&url=https://watson-developer-cloud.github.io/doc-tutorial-downloads/visual-recognition/fruitbowl.jpg&version=2016-05-20"

但是Invoke-RestMethod返回

代码语言:javascript
复制
Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ Invoke-RestMethod -Uri "https://gateway-a.watsonplatform.net/visual-r ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

我的Invoke-RestMethod命令中遗漏了什么?我是否需要指定某种类型的标题或其他东西?

文档链接https://www.ibm.com/watson/developercloud/visual-recognition/api/v3/curl.html?curl#data-collection

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-21 22:04:05

默认情况下,PowerShell在使用Invoke-WebRequest/RestMethod时使用TLS1.0,这可能是您无法建立安全连接的原因。因此,该站点不支持TLS 1.0。

尝试将下面的内容添加到脚本的顶部,以强制执行TLS 1.2。

代码语言:javascript
复制
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49416747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档