DEV Community

Cover image for Get Logic App Workflow using REST API (Postman)
Rakesh Suryawanshi
Rakesh Suryawanshi

Posted on • Edited on

Get Logic App Workflow using REST API (Postman)

Image description

In this article I am sharing how to get logic app workflow details using azure management REST API from postman?

Logic app are serverless offering from Microsoft, it has been evolved a lot in last period or so and its keep on changing, now the logic app service is part of AppService and you need to provision the logic app inside the App service plan... this information might not sound relevant to this blog but it does actually, Microsoft has the rich set of REST API documentation for all different azure services (including logic apps) which we can use to get REST endpoint outcome from these API, incase of logic app RESTAPI the endpoint as of date (May, 04 2022) its still pointing to the standalone workflow instead of logic app being AppService resource type.

Logic App REST API Doc

It means that document say to get the workflow details of logic you need to call logic app endpoint
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}?api-version=2016-06-01

but unfortunately this does not return the output.

Instead of this you need to call following REST API URL:

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{logicapp-name}/workflows/{workflowName}?api-version=2022-03-01

or



https://management.azure.com//subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{logicapp-name}/hostruntime/runtime/webhooks/workflow/api/management/workflows/{workflowName}?api-version=2018-11-01



Enter fullscreen mode Exit fullscreen mode

This a change which Microsoft should make into REST API and I hope they will update the documents very soon, may be it's already update by the time you are reading this blog.

Create Postman collection

Now lets see how to get workflow details using Postman.

In the postman I have create a collection, that collection first of all we need to write pre-request script to create workflow, here the script code which you can use.



pm.sendRequest({
    url: 'https://login.microsoftonline.com/' + pm.collectionVariables.get("TenantID") + '/oauth2/token',
    method: 'POST',
    header: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: {
        mode: 'urlencoded',
          urlencoded: [
            {key: "grant_type", value: "client_credentials"},
            {key: "client_id", value: pm.collectionVariables.get("ClientID")},
            {key: "client_secret", value: pm.collectionVariables.get("ClientSecret")},
            {key: "resource", value: pm.collectionVariables.get("Resource")}
          ]
    }
}, function (err, res) {
    pm.collectionVariables.set("Token", res.json().access_token);
});


Enter fullscreen mode Exit fullscreen mode

we also need service principal to create bearer token and the details of service principal and azure subscription is capture into postman collection variable.

Image description

Create Postman request

in our collection we will add new service request and add get request



https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}?api-version=2016-06-01


Enter fullscreen mode Exit fullscreen mode

Setup authorization for your request and use bearer token variable here

Image description

Once you replace the variable as per your logic app details you are ready to run.

Image description

The output will contains everything about your logic including workflow definition in json format.

That's it really, this a simple example of how to use postman to get the logic app workflow.

In the next blog I will discuss how to trigger logic app workflow from postman, till then please follow me here on dev.to.

You can also follow me on medium blog!!

I also have my YouTube channel please subscribe!! to my channel there.

Top comments (0)