Invoke operator API service¶
Call the published and enabled operator API service. The fields of payload must conform to the input definition of the service; first View Service Configuration confirms that the service can be called and obtains the input definition.
POST $CLOUDSIGMA_API_BASE/workflow/v2/workitems/catalog/$NODE_ID/api-service/invoke
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First View Service Configuration, confirm that the service is enabled, and obtain the operator ID, version and service name of the service to be called.
Request¶
curl -X POST "$CLOUDSIGMA_API_BASE/workflow/v2/workitems/catalog/$NODE_ID/api-service/invoke" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"service_name\": \"$SERVICE_NAME\",
\"type\": \"operator\",
\"version\": \"$VERSION\",
\"payload\": {
\"sql\": \"SELECT now()\"
}
}"
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
node_id | string | Required | The ID of the operator to be called. |
service_name | string | Required | Service name, using data.service.service_name from the service configuration response. |
type | string | Required | Fixed to operator. |
version | string | Required | The published operator version. |
payload | object | the input data of the service; fields and types are subject to data.service.input_schema. |
Successful response¶
data.result returns the status and operator output of this call. result is returned as a JSON format string; the operator output is read after parsing the string. When error appears in the response, handle it as an error message.
The response fields are as follows.
{
"code": "OK",
"msg": "OK",
"data": {
"result": {
"case_id": "case_01JEX4A1M2",
"status": "COMPLETED",
"result": "{\"count\":9}"
}
}
}
| Field | Type | Description |
|---|---|---|
code | string | OK on success. |
msg | string | OK on success. |
data.result.case_id | string | ID of this call; can be used to correlate this result when the response is provided. |
data.result.status | string | The status returned by the service; occurs when the response is provided. |
data.result.result | string | JSON format string returned by the service; the parsed structure is determined by the operator. |
data.result.error | string | Error message returned by the service; appears when there is an error. |
Error response¶
{
"code": "api_service_unavailable",
"msg": "服务暂不可用",
"data": null
}
| Field | Type | Description |
|---|---|---|
code | string | Error code. |
msg | string | Readable error message. |
data | null | `null` in an error response. |
Follow-up operations¶
After the call is completed, when you need to check the configuration View operator API service configuration.