【问题标题】:Create Environment for Watson Discovery API为 Watson Discovery API 创建环境
【发布时间】:2017-10-23 11:39:18
【问题描述】:

我正在尝试创建一个环境以开始使用我在 Bluemix 中创建的 Watson Discovery Service。

按照入门文档,我输入了这段代码(在 cmd 中):

curl -X POST -u "{username}":"{password}" -H "Content-Type: application/json" -d '{ "name":"my-first-environment", "description":"exploring environments", "size":0}' "https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-12-01"

我确定我输入了正确的服务凭据,但我收到了这个我不明白的错误:

{ "code" : 401 , "error" : "Not Authorized" , "description" : "2017-05-23T08:53:35-04:00, Error ERCDPLTFRM-INVLDCHR occurred when accessing https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-12-01, Tran-Id: gateway-dp02-1408488112 - " }

当我在浏览器中键入链​​接并手动输入凭据时,我没有收到任何错误。

是否有人理解这个错误并可以帮助我?

提前致谢并致以最诚挚的问候

埃米拉

【问题讨论】:

    标签: ibm-watson watson-discovery


    【解决方案1】:

    您确定要提供发现服务凭据吗?如果您然后检查您的用户名和密码是否正确。

    当您访问 Discovery Service 时,有一些选项名称为:Service Credentials

    usernamepassword 替换为这些值。

    查看一个示例以访问:

    curl -X POST -u "USERNAME":"PASSWORD" -H "Content-Type: application/json" -d '{ "name":"my-first-environment", "description":"exploring environments", "size":0}' "https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-12-01"
    

    编辑:

     curl -X POST -u "{username}":"{password}" -H "Content-Type: application/json" -d '{ "name": "test_collection", "description": "My test collection", "configuration_id": "{configuration_id}" }' "https://gateway.watsonplatform.net/discovery/api/v1/environments/{environment_id}/collections?version=2016-12-01"
    

    【讨论】:

    • 是的.. 我确定我用正确的凭据替换了!
    • 使用最后一个 cURL 我得到以下错误: curl:(3)非法端口号 curl:(3)非法端口号 curl:(3)[globbing] 列中不匹配的右大括号/括号7 { "code": 400, "error": "Unexpected token '" }
    • 再试一次。您是在尝试创建集合还是添加一些文档?最后一次编辑是添加文档。现在这是为了创建一个集合......基于你的例子是一样的
    • 替换为您的配置 ID 和环境 ID。我测试并完美运行
    猜你喜欢
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-05
    • 1970-01-01
    • 2017-11-09
    • 2018-06-14
    • 1970-01-01
    相关资源
    最近更新 更多