【问题标题】:Invalid Request : Content is Empty无效请求:内容为空
【发布时间】:2019-07-05 02:47:33
【问题描述】:

我刚开始使用 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" ^

【问题讨论】:

    标签: curl ibm-watson watson-nlu


    【解决方案1】:

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

    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"
    
    }'
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 2021-03-06
    • 1970-01-01
    • 2022-10-18
    • 2020-10-21
    • 1970-01-01
    相关资源
    最近更新 更多