0

我刚从 cURL 开始,我正在使用 Watson 自然语言理解 (NLU) 服务。以下行给了我错误代码:400“无效请求,内容为空”

注意:我是 Windows 用户

非常感谢您的帮助!

我要做的就是这个简单的入门示例

https://cloud.ibm.com/services/natural-language-understanding/crn:v1:bluemix:public:natural-language-understanding:us-south:a%2f1fdc918bf6c243fcb853ba8fb6907839:aaf7bfd6-ca63-431a-a143-e2cc863ebc6c: :?paneId=gettingStarted

curl -X POST -u "apikey:{MY_API_KEY}" ^
"https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-11-16" ^

4

1 回答 1

1

嘿@mohsen 上面的 Post 请求中缺少正文,对于文本中的关键字,示例请求看起来像这样,还要在下面的 curl 请求中替换 API-KEY。在公共网站上发布 API 密钥并不理想

curl -X POST \
 'https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2017-01-11' \
-u "apikey:<API-KEY>"\
 -H 'Content-Type: application/json' \
 -H 'cache-control: no-cache' \
 -d '{
   "text":"Iran Warns Of Retaliation If U.S. Breaches Nuclear Deal. Iran Supreme Leader Ayatollah Khamenei is warning that Tehran will retaliate if the sanctions are approved.",
   "features": {
       "keywords":{
           "sentiment":true

       }
   },
   "language":"en"

}'
于 2019-06-20T17:43:03.573 回答