如何找到用于 ibm-watson for Watson Assistant API 使用 nodejs 的 api-key 和密码

How to find api-key and password for ibm-watson for Watson Assistant API working with nodejs

我正在尝试访问我的助手,但在插入仪表板中提供的 iam_api_key 和 url 时出现 404 未找到错误。 而且我在仪表盘里找不到密码。

我正在与 Node.js 合作。我尝试创建其他服务凭据但没有任何效果

{
    username: '{api-key}',
    password: '{password}', // I can't find this
    // OR even
    iam_apikey: '{api-key}'
    url: '{url}',
    version:  '{version}',
    disable_ssl_verification: true,
}

{ Not Found: Resource not found

{ ... }

at at process._tickCallback (internal/process/next_tick.js:188:7) name: 'Not Found', code: 404, message: 'Resource not found',
body: '{"error":"Resource not found","code":404}', headers: { 'x-backside-transport': 'FAIL FAIL', 'content-type': 'application/json; charset=utf-8', 'access-control-allow-origin': '*', 'access-control-allow-methods': 'GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS', 'access-control-allow-headers': 'Content-Type, Content-Length, Authorization, X-Watson-Authorization-Token, X-WDC-PL-OPT-OUT, X-Watson-UserInfo, X-Watson-Learning-Opt-Out, X-Watson-Metadata', 'access-control-max-age': '3600', 'content-security-policy': 'default-src \'none\'', 'x-dns-prefetch-control': 'off', 'x-frame-options': 'SAMEORIGIN', 'strict-transport-security': 'max-age=31536000;', 'x-download-options': 'noopen', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'x-global-transaction-id': '{x-global-transaction-id}', 'x-dp-watson-tran-id': '{x-dp-watson-tran-id}', 'x-dp-transit-id': '{x-dp-transit-id}', 'content-length': '41', 'x-edgeconnect-midmile-rtt': '124', 'x-edgeconnect-origin-mex-latency': '142', date: 'Wed, 19 Jun 2019 20:38:08 GMT', connection: 'close' } }

您必须使用 api 键或用户名/密码组合。 API docs for IBM Watson Assistant have code samples for Node.js:

const AssistantV2 = require('ibm-watson/assistant/v2');

const assistant = new AssistantV2({
  version: '{version}',
  iam_apikey: '{apikey}',
  url: '{url}'
});

同样使用此代码。它对我有用。我添加了 serviceUrl 和 headers。确保根据助手URL.

添加正确的服务URL
const assistant = new AssistantV2({
  version: "2019-02-28",
  authenticator: authenticator,
  url: process.env.WATSON_ASSISTANT_URL,
  serviceUrl: "https://api.us-south.assistant.watson.cloud.ibm.com",
  headers: {
    "X-Watson-Learning-Opt-Out": "true",
  },
});

参考更多 - https://cloud.ibm.com/apidocs/assistant-v2?code=node#endpoint-cloud