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:
No comments:
Post a Comment