-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathNode-Red-API-call
125 lines (125 loc) · 3.08 KB
/
Node-Red-API-call
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
[
{
"id": "82406bea.02f7f8",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "c039d087.3c18",
"type": "inject",
"z": "82406bea.02f7f8",
"name": "",
"topic": "",
"payload": "{\"fields\":[\"CreditScore\",\"Geography\",\"Gender\",\"Age\",\"Tenure\",\"Balance\",\"NumOfProducts\",\"HasCrCard\",\"IsActiveMember\",\"EstimatedSalary\",\"Exited\"],\"values\":[[500,\"Spain\",\"Male\",50,2,10000,2,1,0,40000,-1]]}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 110,
"y": 100,
"wires": [
[
"c5e7faa1.d5d5d8"
]
]
},
{
"id": "c5e7faa1.d5d5d8",
"type": "function",
"z": "82406bea.02f7f8",
"name": "Token header",
"func": "msg.fields=msg.payload;\nmsg.headers={\"Content-type\":\"application/json\"}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 280,
"y": 100,
"wires": [
[
"561b2a5e.6147a4"
]
]
},
{
"id": "561b2a5e.6147a4",
"type": "http request",
"z": "82406bea.02f7f8",
"name": "Token request",
"method": "GET",
"ret": "txt",
"url": "https://ibm-watson-ml.mybluemix.net/v3/identity/token",
"tls": "",
"x": 480,
"y": 100,
"wires": [
[
"748e0136.7db3a"
]
]
},
{
"id": "748e0136.7db3a",
"type": "function",
"z": "82406bea.02f7f8",
"name": "Grab token",
"func": "msg.token = JSON.parse(msg.payload).token;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 650,
"y": 100,
"wires": [
[
"ad493f30.9a8f2"
]
]
},
{
"id": "ad493f30.9a8f2",
"type": "function",
"z": "82406bea.02f7f8",
"name": "Scoring header",
"func": "msg.headers={\"Content-type\": \"application/json\",\"Authorization\":\"Bearer \" + msg.token}\nmsg.payload=msg.fields;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 160,
"y": 300,
"wires": [
[
"3b8ca80b.c06aa8"
]
]
},
{
"id": "3b8ca80b.c06aa8",
"type": "http request",
"z": "82406bea.02f7f8",
"name": "Scoring request",
"method": "POST",
"ret": "txt",
"url": "poner aquí scoring end point",
"tls": "",
"x": 360,
"y": 300,
"wires": [
[
"85b425f3.34a078"
]
]
},
{
"id": "85b425f3.34a078",
"type": "debug",
"z": "82406bea.02f7f8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 550,
"y": 300,
"wires": []
}
]