[英]How to find api-key and password for ibm-watson for Watson Assistant API working with nodejs
我正在嘗試訪問我的助手,但在插入 iam_api_key 和儀表板中提供的 url 時出現 404 Not Found 錯誤。 而且我在儀表板中找不到密碼。
我正在使用 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,
}
{ 未找到:未找到資源
{ ... }
在 process._tickCallback (internal/process/next_tick.js:188:7) 名稱:'未找到',代碼:404,消息:'找不到資源',
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-內容類型選項':'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',日期:'Wed, 19 Jun 2019 20:38:08 GMT',連接:'close' } }
您必須使用 api 密鑰或用戶名/密碼組合。 IBM Watson Assistant的API 文檔包含 Node.js 的代碼示例:
const AssistantV2 = require('ibm-watson/assistant/v2');
const assistant = new AssistantV2({
version: '{version}',
iam_apikey: '{apikey}',
url: '{url}'
});
也使用此代碼。 它在我身上起作用。 我添加了 serviceUrl 和標題。 確保根據助手 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.