Get Logic App Workflow using REST API (Postman)
Tags: azure, postman, logicapps, devops
Published: 2022-05-05 14:14:46



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s4232pnagojv03c6rsaw.png)

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](https://docs.microsoft.com/en-us/rest/api/logic/workflows/get) 

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

```url
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

```

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.

```javascript
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);
});
```
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t67ayq1zy7uw8ehrkmpn.png)

## 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
```

Setup authorization for your request and use bearer token variable here


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpx4cdjywaio4uz42kj3.png)


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hp4c2z6vcyi34qzazer9.png)

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](https://rakesh-suryawanshi.medium.com/)!!

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

{% youtube 6DZnydHPJPc %}