Tuesday, 1 July 2025

Triggering a Microsoft Flow using a Webpage or HTTP GET Request

 There are several use cases where you may want to run a Microsoft Flow from a web page or sending an HTTP GET request. Let’s do this. We will create a flow that runs when a user accesses a web address and performs the action of posting to a Microsoft Teams chat.

First, let’s create an Instant Microsoft Flow by going to https://flow.microsoft.com and selecting New->Instant – From Blank:

We will call the flow Send Alert from HTTP, and select When an HTTP request is received, then click Create:

This takes us to the Flow designer. Click New step:

We will choose Microsoft Teams:

And Post a Message

Now let’s fill in the details for our Teams message. We will post to our Warehouse Team, General Channel with the message “Stock is low, please resupply”:

For the method, let’s choose GET:

We can see an HTTP GET URL has been generated. Copy the link:

And let’s go to that web address by pasting it into a browser:

On hitting the web page, we can see our Flow is run and the message is posted to our Teams chat:

 

Triggering a Microsoft Flow POST Request from Postman

 In a previous post, we looked at how to trigger a Microsoft Flow using a GET request. In this post, we will show how to trigger a request using POST. We will do this using the Postman application to simulate our POST. We will use the same example as with the GET, where we post to a Microsoft Teams chat when the request comes in. Additionally, in our POST we will pass a variable and write it out to the chat.

First, create a new Microsoft flow by going to https://flow.microsoft.com and selecting New->Instant – From Blank:

We will call it Send Alert from HTTP and trigger When an HTTP request is received:

Now, you will see below. Set the method to POST:

Now when we send our POST request, let’s add some functionality to also send a variable in the body, which we will use in our post. Previously in our chat we wrote out “Stock is low, please resupply.”

Now let’s pass a Product variable to show which item is out of stock.

To do this, we will need to pass JSON in the body.

Select Use sample payload to generate schema:

We want to pass our product, so it should look like:

{
  "product": "test"
}

Paste this in and click Done:

You will now see the schema generated:

Next, click Add Step and add a Microsoft Teams Post Message action. We will see product appearing as Dynamic content now. Add that to the message for our chat:

Click Save and we’re ready to run our Flow. Copy the HTTP POST URL:

Open Postman and let’s create a POST request. Create a new request:

Give the request a name, etc and click Save to Flow:

Set the request to POST and paste in the URL copied above:

Go to Headers and set key=Content-Type value=application/json:

In the body, pass in the JSON. We will send a product called ABC123. Press Send:

{
  "product": "ABC123"
}

On sending, we see in our Teams chat the request has come through:

How To Extract Data From Web Page Using Power Automate

 Power Automate cloud flows can be used to extract data from a web page. You can get the web page HTML by using an HTTP action and output its details with an AI Prompt. This technique will only work on web pages where text is included when the initial page is loaded. When the text is generated after the page loaded (JavaScript, client-side rendering, etc.) you will need to use Power Automate Desktop instead.

Introduction: The Get Contract Details Automation

A construction firm uses a Power Automate cloud flow to read a government website and extract details about the contracts awarded each day.



The contract details are output in JSON format. From there the construction firm can save the contracts to a SharePoint list, a Dataverse table, etc.




Get The Web Page HTML Using The HTTP Action

Open Power Automate and create a new instant flow named Get Webpage Plain Text.



Add an HTTP action to the flow to get the web page HTML.



Use the GET method to request the web page.

GET



Input the URL of the website we want to extract data from.

https://www.defense.gov/News/Contracts/Contract/Article/4032268/



Then use the Header Accept text/html. This tells the server it should respond with the web page html.

KeyValue
Accepttext/html




Convert The Web Page HTML to Plain Text

The HTTP action will return the HTML for the web page but we only want the text displayed to the user. Insert an HTML to text action into the flow. Then supply the body of the HTTP action into the content field.



The web page content is output as plain text with all of the HTML tags removed.




Create An AI Prompt To Extract Data From Web Page Text

We want to extract the details of all contracts from the contract text. To do this we can build an AI Prompt. Go to the AI Prompts menu and choose build your own prompt.



Name the AI Prompt Extract Government Contract Announcement Details.



Use this prompt to instruct the large-language model what details should be output.

I want you to read an announcement of contracts awarded by Department of Defense. Make a list of all the contracts and provide the following information if it is available:

Contractor Name: the name company who was awarded the contract.
Contractor City: the city where the Contractor is located.
Contractor State: the state where the Contractor is located. Must be a 2-letter state code.
Amount: the amount awarded to the Contractor. Must be a number value.
Completion Date: when the work is expected to be completed. Date must be in the format YYYY-MM-DD
Work Description: the goods or services being provided by the Contractor
Work City: the city where the work will be performed
Work State: the state where the work will be performed
Contracting Branch: the branch of the military the contracted the work
Contracting Agency: the government agency who contracted the work
Contracting Activity: the alphanumeric unique identifier of the contracting activity
Contract: the alphanumeric unique identifier of the contract

Here is the announcement of contracts text:




Input The Web Page Text As A Variable In An AI Prompt

The web page text must be included in the prompt for the AI to evaluate it. To do this, create a new input variable named ContractsText and insert it at the end of the prompt. Use the web page plain text as sample data.



Choose the output format JSON and then test the prompt. We can now see the contract details output in the prompt response. Press the save custom prompt button and exit the prompt editor menu.




Run The Power Automate Flow To Extract Web Page Data

We are now done building the flow to extract contract details from the web page. Run the flow to ensure it works.



A JSON array of contracts is output by the AI Prompt and each item can be saved to SharePoint as a new list item or to Dataverse as a new record, etc.


Connect to Dynamics CRM with Data verse from Azure Function

 In this blog, we'll connect to Dataverse using an Azure function that utilizes the.Net core 6.2 framework.

The prerequisites are listed below.
  • Create a new Dynamics 365 application in Azure.
  • Make that the newly created Azure Function builds appropriately.
  • To establish a connection with the Dataverse, use this sample of code.
Create a new Dynamics 365 application in Azure:

We need to register the Dynamics 365 Web API on Azure and use it with an application user. This is particularly useful for those working with custom APIs in CRM.

To achieve this, you will need the following components.
  • Azure portal access
  • Application user
  • CRM Admin user
Log in to the Azure portal, search for " Microsoft Entra ID," and click on it.


Fill in the required details and shown below the preferred options. I selected the first option, which is for single-tenant users only. Once completed, click on "Register." An application (Dynamics 365) will be registered, and its details will be available in the Overview tab.



Application ID – The Application ID is a unique, unchangeable identifier for this application. Directory (Tenant) ID – The Tenant ID is the identifier of the AAD directory where the application was created. Next, you need to grant permissions to the API. Refer to the screenshot below.






Navigate to API permissions, click on "Add a permission," and select "Dynamics CRM." Choose delegated permissions and check the "user impersonation" option. Finally, click on "Add permissions.



Here are the reasons for enabling user impersonation in the application:
  • The user calls the API with another AAD ID in the header.
  • The user is authenticated as a valid AAD user.
  • Permissions are checked to determine if the user can impersonate.
  • The AAD ID is read from the header.
  • Every call is now made as if it is by the user specified in the AAD ID header (including calls to Graph API, Dynamics CRM, etc.)
After granting permissions, the next step is to create a client secret ID.



Add a new client secret and select its expiration date.



Click on "Add" to generate a client secret. Please save the client secret in a notepad file. Refer to the screenshot below for guidance.


We have successfully deployed the Dynamics online Web API. Now, let's proceed to create an application user in CRM.
Navigate to https://admin.powerplatform.microsoft.com/ and select your environment and click on setting as shown in below screen short.



Next under Users and permissions click on application users.



Click on New app user.



Choose the app registered in Azure, then assign it to the appropriate business unit and add the desired security roles. In my case, I added the admin role to my app.



Let's test the API on Postman.
To consume the Web API, first, we need to generate an authorization token. This can be done by making a GET API call to the following endpoint:
URL:https://login.microsoftonline.com/<TENANT ID>/oauth2/token



Please include the following parameters in the API body:
  • client_id: This should be the client ID of the registered Azure application.
  • client_secret: This will be the value of the client secret generated in certificate and secrets.
  • resource: The value of this parameter will contain the URL of the CRM instance.
  • grant_type: This parameter will have a value of client_credentials.
The Client Credentials grant type is utilized by clients to obtain an access token outside of the context of a user. Upon making the request above, we will receive an access_token in return with a status code of 200.
I am obtaining CRM contacts by using an odata query in the request provided above. The details of the request are given below. The method used is Get. The URL is
https://org18828102.crm5.dynamics.com/api/data/v9.2/contacts
The above URL can be accessed by navigating to SettingsàCustomization Ã  Developer resources, and finally to Service root URL.



This token is intended for performing CRUD operations via WEBAPI. I will provide an example of a GET request used to retrieve data from CRM.



Create Azure Function builds appropriately:
I am writing below Azure function to create a contact record through the Service client.
The subsequent action involves deploying the Azure function and then conducting a test using Postman or a web browser.
Conducting a test of the Azure function using Postman.

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Microsoft.PowerPlatform.Dataverse.Client;
using Microsoft.Xrm.Sdk;
using System.Collections.Generic;

namespace CreateContactfromAzurefunction
{
    public static class Function1
    {
        [FunctionName("Createcontactrecord")]
        public static async Task<IActionResult> Run(
    [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
    ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
            var _contactid = new Guid();
            try
            {
                string _clientId = "e69c80b6-615d-4c4f-97c5-88c9306e1aae";
                string _clientSecret = "sPZ8Q~152D_aVvp4TO_Fxem7iTLSP0B4Ab1OOaqI";
                string _environment = "org18828102.crm5";
                var _connectionString = @$"Url=https://{_environment}.dynamics.com;AuthType=ClientSecret;ClientId={_clientId}
                ;ClientSecret={_clientSecret};RequireNewInstance=true";


                var service = new ServiceClient(_connectionString);
                if (service.IsReady)
                {
                    _contactid = await GetContacts(service);
                }


            }
            catch (Exception ex)
            {
              return  new  OkObjectResult(ex.Message);
                throw new(ex.Message);

            }
            OkObjectResult testrecord = new OkObjectResult("Contact Record created with ID " + Convert.ToString(_contactid));
            return testrecord;
        }

        private static async Task<Guid> GetContacts(ServiceClient service)
        {
            Guid _contactid;
            // Create a contact
           
            Entity contact = new Entity("contact")
            {
                ["firstname"] = "Rahman",
                ["lastname"] = "Dynamics CRM"
            };
            _contactid = service.Create(contact);
            return  _contactid;
        }

       
    }
}
Copy the local host URl and send post request from postman as shown in below screen.




Below records is created in dynamic in contact entity.



Thank you...!
​​​​​​​

Triggering a Microsoft Flow using a Webpage or HTTP GET Request

  There are several use cases where you may want to run a Microsoft Flow from a web page or sending an HTTP GET request. Let’s do this. We w...