# Watson Machine Learning & Node-RED

**URL:** <https://discourse.nodered.org/t/watson-machine-learning-node-red/15291>\
**Category:** General\
**Created:** [9 September 2019 07:01 UTC](https://discourse.nodered.org/t/watson-machine-learning-node-red/15291 "2019-09-09T07:01:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandra](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sandra/32/3010_2.png) [@sandra](https://discourse.nodered.org/u/sandra)\
**Post date:** [9 September 2019 07:01 UTC](https://discourse.nodered.org/t/watson-machine-learning-node-red/15291/1 "2019-09-09T07:01:59Z")

</div>

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](https://iam.bluemix.net/identity/token)"

Thanks!!

---

<div class="post-metadata">

**Author:** ![sandra](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sandra/32/3010_2.png) [@sandra](https://discourse.nodered.org/u/sandra)\
**Post date:** [9 September 2019 07:14 UTC](https://discourse.nodered.org/t/watson-machine-learning-node-red/15291/2 "2019-09-09T07:14:12Z")

</div>

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;
