Watson Machine Learning & Node-RED

Hi!

I have my model deployed with Watson Machine Learning and I want to call it from Node-RED.
In the past I used a node called 'node-red-contrib-watson-machine-learning' but with the new authentication methods is not working.

Once I get my token (using Curl) the prediction REST call works perfectly, but I get errors when trying to get the token in Node-RED.

These are the CURL details I need to translate to Node-RED:
curl -k -X POST
--header "Content-Type: application/x-www-form-urlencoded"
--header "Accept: application/json"
--data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey"
--data-urlencode "apikey=123456789"
"https://iam.bluemix.net/identity/token"

Thanks!!

I was too fast asking..

It works like this:

var apikey="12345";
msg.headers = {'Content-Type': 'application/x-www-form-urlencoded'};

msg.payload = { 'apikey' : apikey,
'grant_type': 'urn:ibm:params:oauth:grant-type:apikey' };
return msg;

1 Like