forked from cicenet/ws
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathNode-Red-API-call.json
1 lines (1 loc) · 2.27 KB
/
Node-Red-API-call.json
1
[{"id":"baec9f05.6bca6","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"6c5740c8.ae604","type":"inject","z":"baec9f05.6bca6","name":"","topic":"","payload":"{\"fields\":[\"CreditScore\",\"Geography\",\"Gender\",\"Age\",\"Tenure\",\"Balance\",\"NumOfProducts\",\"HasCrCard\",\"IsActiveMember\",\"EstimatedSalary\"],\"values\":[[500,\"Spain\",\"Male\",50,2,10000,2,1,0,40000]]}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["2de2e5e6.d8b1aa"]]},{"id":"2de2e5e6.d8b1aa","type":"function","z":"baec9f05.6bca6","name":"Token header","func":"msg.fields=msg.payload;\nmsg.headers={\"Content-type\":\"application/x-www-form-urlencoded\",\n\"Accept\":\"application/json\"};\n\n//Agregar el apikey de las credeciales de Watson Machine Learning\napikey = \"\";\n\nmsg.payload = \"apikey=\" + apikey + \"&grant_type=urn:ibm:params:oauth:grant-type:apikey\";\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":100,"wires":[["d06b7723.ed7a38"]]},{"id":"d06b7723.ed7a38","type":"http request","z":"baec9f05.6bca6","name":"Token request","method":"POST","ret":"txt","paytoqs":false,"url":"https://iam.bluemix.net/identity/token","tls":"","proxy":"","x":480,"y":100,"wires":[["75ec7711.5549c8"]]},{"id":"75ec7711.5549c8","type":"function","z":"baec9f05.6bca6","name":"Grab token","func":"msg.token = JSON.parse(msg.payload).access_token;\nreturn msg;","outputs":1,"noerr":0,"x":661,"y":100,"wires":[["ea0d0e9f.2aabd"]]},{"id":"ea0d0e9f.2aabd","type":"function","z":"baec9f05.6bca6","name":"Scoring header","func":"//Agregar el instance id de las credenciales de Watson Machine Learning\ninstance_id = \"\" ;\n\nmsg.headers={\"Content-type\": \"application/json\",\n\"Authorization\":\"Bearer \" + msg.token,\n\"ML-Instance-ID\": instance_id\n};\nmsg.payload=msg.fields;\nreturn msg;","outputs":1,"noerr":0,"x":160,"y":300,"wires":[["479801b1.aad7e"]]},{"id":"479801b1.aad7e","type":"http request","z":"baec9f05.6bca6","name":"Scoring request","method":"POST","ret":"txt","paytoqs":false,"url":"PON AQUI EL SCORING ENDPOINT","tls":"","proxy":"","x":360,"y":300,"wires":[["1a8b0f6f.222221"]]},{"id":"1a8b0f6f.222221","type":"debug","z":"baec9f05.6bca6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":550,"y":300,"wires":[]}]