I created a simple program for testing. I just wanted to ping the Watson Discovery server for Env details (https://www.ibm.com/watson/developercloud/discovery/api/v1/?node#list_environment_details).
const dotenv = require( 'dotenv');
dotenv.config()
const DiscoveryV1 = require('watson-developer-cloud/discovery/v1');
var discovery = new DiscoveryV1({
username: process.env.USERNAME,
password: process.env.PASSWORD,
version_date: '2017-11-07'
});
discovery.getEnvironments({}, function(error, data) {
console.log('Env:', JSON.stringify(data, null, 2));//returns data
//doesn't appear to be called
discovery.getEnvironment({ environment_id: process.env.ENVIRONMENT}), function(error, data) {
if (error){
console.log('Env Details', JSON.stringify(error, null, 2));
}
console.log('Env Details', JSON.stringify(data, null, 2));
};
});
the result node index.js
Env: {
"environments": [
{
"environment_id": "system",
"name": "Watson System Environment",
"description": "Shared system data sources",
"read_only": true
},
{
"environment_id": "my value",
"name": "byod",
"description": "",
"created": "2018-01-24T14:52:47.736Z",
"updated": "2018-01-24T14:52:47.736Z",
"read_only": false
}
]
}
I can get it to work with a curl command, so I know I have the right information. It is just the node calls.
curl -u "{username}":"{pw}" "https://gateway.watsonplatform.net/discovery/api/v1/environments/my value?version=2017-11-07"