restApiCall
restApiCall
component: call rest api. Call an external REST service. msg.Data will be filled in the body and request the REST service, and the request return value will be filled back to msg.Data.
# Configuration
Field | Type | Description | Default value |
---|---|---|---|
restEndpointUrlPattern | string | HTTP URL address, can using Component Configuration Variables. | None |
requestMethod | string | Request method | POST |
withoutRequestBody | bool | without request body | false |
headers | map | Request header, can using Component Configuration Variables. | "Content-Type": "application/json" |
readTimeoutMs | int | Timeout, in milliseconds | 2000 |
maxParallelRequestsCount | int | Maximum concurrency size | 200 |
enableProxy | bool | Whether to enable proxy | false |
useSystemProxyProperties | bool | Whether to use system configuration proxy | false |
proxyHost | string | Proxy host | None |
proxyPort | int | Proxy port | None |
proxyUser | string | Proxy username | None |
proxyPassword | string | Proxy password | None |
proxyScheme | string | Proxy protocol | None |
Placeholder
restEndpointUrlPattern
and headers
support using ${metaKeyName} to replace metadata data. (Note: ${}
cannot contain spaces)
# Relation Type
- Success: Execution successful, send the message to the
Success
chain - Failure: Execution failed, send the message to the
Failure
chain
# Execution result
- Execution successful: http response body data, replace to msg.Data, and pass to the next node
- msg.Metadata.status: Save the response code.
- msg.Metadata.statusCode: Save the response code.
- Execution failed:
- msg.Metadata.status: Save the response code.
- msg.Metadata.statusCode: Save the response code.
- msg.Metadata.errorBody: Response error information.
# Configuration example
{
"id": "s1",
"type": "restApiCall",
"name": "Push data",
"configuration": {
"restEndpointUrlPattern": "http://192.168.136.26:9099/api/msg",
"requestMethod": "POST",
"maxParallelRequestsCount": 200
}
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
You can also call large model streaming responses in the following way:
{
"id": "s2",
"type": "restApiCall",
"name": "Call restApi",
"configuration": {
"restEndpointUrlPattern": "http://127.0.0.1:8080/sse",
"requestMethod":"GET",
"headers":{"Accept":"text/event-stream"},
"maxParallelRequestsCount": 200
}
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# Application example
Call rest api.
{
"ruleChain": {
"id":"rule01",
"name": "Test rule chain",
"root": true
},
"metadata": {
"nodes": [
{
"id": "s1",
"type": "jsTransform",
"name": "Transform",
"configuration": {
"jsScript": "metadata['name']='test02';\n metadata['index']=22;\n msg['addField']='addValue2'; return {'msg':msg,'metadata':metadata,'msgType':msgType};"
}
},
{
"id": "s2",
"type": "restApiCall",
"name": "Push data",
"configuration": {
"restEndpointUrlPattern": "http://192.168.136.26:9099/api/msg",
"requestMethod": "POST",
"maxParallelRequestsCount": 200
}
}
],
"connections": [
{
"fromId": "s1",
"toId": "s2",
"type": "Success"
}
]
}
}
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
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
Edit this page on GitHub (opens new window)
Last Updated: 2024/10/23, 10:13:01