I'm trying to use Power Automate to capture a webhook that is being generated by an outside/closed system.
In Power automate I just have simple trigger that is: "When a HTTP request is received" followed by a parser and 200 response.
I can simulate receiving the data using Postman with no issues when using no additional authentication in the header.
When the actual system generates the webhook call, it includes a Bearer token in the header.
As a result I get the following error: error 401
{
"error": {
"code": "DirectApiRequestHasMoreThanOneAuthorization",
"message": "The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used."
}
}
Unfortunately, I can't modify anything in the system that generates the webhook.
I can only subscribe to it as is.
Is there a way to set the Flow HTTP API trigger to ignore the Bearer token and not fail since it now has both (Bearer token and SAS auth)?
Thank you
Oren
@OrenLevy , can you pass along any resources for how to duplicate that setup? I've never used the Azure Function App or any Azure services before, and creating a new Function App asks you loads of questions that I don't know how to answer. Any pointers in the right direction would be greatly appreciated.
Hi @divdivsays
I created an Azure function that consumes the webhook and then redirects it to Power Automate (flow).
The Azure function is more forgiving and I just redirect the payload to flow.
I created an Azure function (with no authentication/security).
I added a parameter to the Azure function endpoint url called "disp" to identify the source of the webhook.
Below is the code for the Azure function (they are free up to a certain SLA/consumption).
In a nutshell:
Let me know if that worked for you.
Regards
Oren Levy
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using System.Text;
using System.Net.Http;
private static HttpClient httpClient = new HttpClient();
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
string disp = "";
string flowUrl = "";
log.LogInformation("C# HTTP trigger function processed a request.");
// used this additional parameter in the webhook url to identify the source
string name = req.Query["disp"];
disp = name;
flowUrl = "ENTER YOUR FLOW HTTP POST URL";
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
//convert original request to string
string dataJson = Convert.ToString(data);
//added a json wrapper on top of the original payload to be able to include the source
dataJson = "{"+ ((char)34).ToString() + "disp"+ ((char)34).ToString() + ": "+ ((char)34).ToString() + disp + ((char)34).ToString() + ","+ ((char)34).ToString() + "wrapper_data"+ ((char)34).ToString() + ": " + dataJson + "}";
string responseMessage = string.IsNullOrEmpty(name)
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
: $"Hello, {name}, {name}. This HTTP triggered function executed successfully.";
//create the httpcontent to be sent as a post.
var httpContent = new StringContent(dataJson, System.Text.Encoding.UTF8, "application/json");
//send the Post
var response = await httpClient.PostAsync(flowUrl,httpContent);
return new OkObjectResult(dataJson);
}
Hi @OrenLevy - really keen on hearing how you solved for this?
Facing the same exact issue - on capturing a webhook and not able to modify anything on their side to get around the SAS + Bearer Auth schemes error.