Tag Archives: customconnector

How to create custom connector to get the flow run history

Here are the steps to create the custom connector to get the specified flow run history in a specified environment.

Swagger file:

swagger: '2.0'
info: {title: Flow Run History, description: '', version: '1.0'}
host: us.api.flow.microsoft.com
basePath: /
schemes: [https]
consumes: []
produces: []
paths:
  /providers/Microsoft.ProcessSimple/environments/{environment_name}/flows/{flow_name}/runs:
    get:
      responses:
        default:
          description: default
          schema: {}
      summary: Get Flow Run History
      description: Get the run history of specified flow in specified environment
      operationId: GetFlowRunHistory
      x-ms-visibility: important
      parameters:
      - {name: environment_name, in: path, required: true, type: string, default: Default-82e5f1fb-9ffd-49c1-b0e1-1aae52374ff1,
        x-ms-visibility: important, description: Environment ID}
      - {name: flow_name, in: path, required: true, type: string, default: 39190573-dbe9-40a2-a99f-183bb2a3fd31,
        x-ms-visibility: important, description: Flow ID}
      - {name: api-version, in: query, required: true, type: string, default: '2016-11-01'}
definitions: {}
parameters: {}
responses: {}
securityDefinitions:
  oauth2_auth:
    type: oauth2
    flow: accessCode
    authorizationUrl: https://login.windows.net/common/oauth2/authorize
    tokenUrl: https://login.windows.net/common/oauth2/authorize
    scopes: {}
security:
- oauth2_auth: []
tags: []

Please make sure you are Adding the Activity.Read.All and Flows.Read.All permissions.

  • Next steps is to Navigate to make.powerapps.com. In the left navigation bar traverse to Dataverse->Custom Connectors and create a new custom connector (Create from blank).
  • Please provide the custom connector name and click on continue. You will be redirected to the below page.
  • In the above image you will be seeing an option called Swagger editor. Please click on it, then it will redirect you to the below page.
  • In the left side black screen, please copy and paste the swagger code which I have mentioned above. Once it is done, please click on update connector. It will navigate you to the security tab.
  • Under Authentication type, you can see the option to edit. Then please enter Client Id, Client Secret and Resource URL: https://service.flow.microsoft.com/ and click on continue. It will navigate you to the definition tab.
  • In the definition tab, you can see the GetFlowRunHistory Action as below. The request has the environment id, flow id, and api-version as input.

You can test this custom connector by passing the environment id, flow id and api version (by default value is 2016-11-01). After testing you can come outside of this custom connector and navigate to Power Automate and add this connector as a action. You will be see the below image inside your Power Automate.

Thanks for reading.

If you are interested in this topic and would like to do some further self-study, I encourage you to check out my blog on this.