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

I’m trying to access my assistant but I’m getting a 404 Not Found error when inserting the iam_api_key and the url provided in the dahsboard. And I can’t find the password in the dahsboard.

I’m working with Node.js. I’ve tried to create other service credentials but nothing worked

{
    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’ } }

Answer

You have to use either the api key OR the username / password combination. The 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}'
});

Leave a Reply

Your email address will not be published. Required fields are marked *