Trigger Flow

Trigger workflow scheduling manually.

Prerequisites

  1. The user must be the owner of the workflow.

  2. Both the user and the workflow are not locked.

Request Format

POST https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=trigger&userId={}&orgId={}

Request Parameters (URI)

Name

Location (Path/Query)

Required or Not

Data Type

Description

userId

Query

true

String

User ID. How to get userId>>

orgId

Query

true

String

Organization ID which the user belongs to. How to get orgId>>

Request Parameters (Body)

Name

Required or Not

Data Type

Description

flowId

true

Integer

Workflow ID

triggerTime

true

Long

Specify the planned scheduling time of the workflow, by the following rules:

  • If the triggering time is before the current time, the workflow will be triggered immediately, and the triggering time will be passed into the time parameters for calculation.

  • Workflow only allows one instance to run at the same time. If the pre-run instance conflicts with a running instance, it will be executed in sequence.

Response Parameters

Name

Data Type

Description

data

FlowInstanceId Struct

Workflow instance information. See FlowInstanceId Struct

FlowInstanceId Struct

Sample

{
  "flowInstanceId": "2430-20190718075000"
}

Parameters

Name

Data Type

Description

flowInstanceId

String

ID of the workflow instance

Error Code

Code

Message

Description

62104

This workflow has no task. You cannot trigger it.

The workflow does not have any task.

62109

Server internal exception

Server internal exception

Sample

Request Sample

url: https://{apigw-address}/dataflow-batch-service/v2.0/ flows?action=trigger&userId={}&orgId={}

method: POST

{
  "flowId":3377,
  "triggerTime":1574385824000
}

Return Sample

{
  "status": 0,
  "msg": " Success",
  "data": {
    "flowInstanceId": "2791-19700101000000"
  }
}

Java SDK Sample

import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;

public 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;
    }
}

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 = "**************";
        String secretKey = "**************";

        //Create a request and save the required parameters in the map of the Query.
        Request request = new Request();
        request.setQueryParam("userId"," your_userId");
        request.setQueryParam("orgId","your_orgId");
        HashMap<String,Object> hashMap = new HashMap<String, Object>(2);
        hashMap.put("flowId",3377);
        hashMap.put("triggerTime",1574385824000);
        request.setBodyParam(hashMap);
        request.setMethod("POST");

        try {
            JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
                    .url("https://{apigw-address}/dataflow-batch-service/v2.0/ flows?action=trigger")
                    .getResponse(request, JSONObject.class);

            System.out.println(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }