Trigger Flow From Task¶
Manually trigger a workflow schedule (run a specified task and its downstream nodes only).
Prerequisites¶
The user must be the owner of the workflow.
Both the user and the workflow are not locked.
Request Format¶
POST https://{apigw-address}/batch-processing-service/v2.1/flows
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|---|
userId |
Query |
Mandatory |
String |
The user ID. How to get userId>> |
orgId |
Query |
Mandatory |
String |
The organization ID which the user belongs to. How to get orgId>> |
action |
Query |
Mandatory |
String |
Fixed value: triggerFromTask |
Request Parameters (Body)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
flowId |
Mandatory |
Integer |
The workflow ID. |
taskId |
Mandatory |
Integer |
Task node ID (running this task node and its downstream nodes). |
triggerTime |
Mandatory |
Long |
Specify the trigger time of the workflow, keeping in mind the following rules:
|
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
FlowInstanceId Struct |
The details of the workflow instance. For more information, see FlowInstanceId Struct |
Error Code¶
Code |
Message |
Description |
---|---|---|
62102 |
Invalid request body. |
The request body format is not correct, or the specified parameters are not valid. |
62102 |
Cannot create workflow instance. Please check if the workflow or task exist, and do not trigger the same workflow repeatedly in 1 minute. |
Failed to create the workflow instance. Please check if the specified workflow ID or task node ID is correct. |
62109 |
Internal server exception |
Internal server exception. |
For other error codes, see Common Error Codes.
Sample¶
Request Sample¶
url: https://{apigw-address}/batch-processing-service/v2.1/flows?action=triggerFromTask&userId={}&orgId={}
method: POST
{
"flowId": 3377,
"taskId":108580,
"triggerTime": 1594016819108
}
Return Sample¶
{
"code": 0,
"msg": "OK",
"data": {
"flowInstanceId": "3377-20200706062600"
}
}
Java SDK Sample¶
import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envision.apim.poseidon.request.PoseidonRequest;
import java.util.HashMap;
import java.util.Map;
public class SampleCode{
public static class Request extends PoseidonRequest {
public void setQueryParam(String key, Object value){
queryParams().put(key, value);
}
public void setHeaderParam(String key, String value){
headerParams().put(key, value);
}
public void setBodyParam(Map<String, Object> bodyPara){
bodyParams().putAll(bodyPara);
}
public void setMethod(String method) {
this.method = method;
}
private String method;
public String baseUri() {
return "";
}
public String method() {
return method;
}
}
@Test
public void triggerImmediatelyTest(){
//1. Select Application Registration from the left navigation bar of EnOS Console.
//2. Open the App Detail page to get the AccessKey and SecretKey of the application.
String accessKey = "AccessKey of your APP";
String secretKey = "SecretKey of your APP";
//Create a request and save the required parameters in the map of the Query.
Request request = new Request();
HashMap<String,Object> hashMap = new HashMap<String, Object>(2);
hashMap.put("flowId", 3377);
hashMap.put("taskId", 108580);
hashMap.put("triggerTime",System.currentTimeMillis()+60*1000);
request.setBodyParam(hashMap);
request.setMethod("POST");
try {
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
.url("https://{apigw-address}/batch-processing-service/v2.1/flows")
.queryParam("orgId", "yourOrgId")
.queryParam("userId", "yourUserId")
.queryParam("action", "triggerFromTask")
.getResponse(request, JSONObject.class);
System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
}
}