Skip to main content

Notifications

Power Automate - Using Connectors
Answered

HTTP request with Bearer Token

(1) ShareShare
ReportReport
Posted on by 21

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

  • DanielGAJohnson Profile Picture
    DanielGAJohnson 93 on at
    Re: HTTP request with Bearer Token

    @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.

  • Verified answer
    OrenLevy Profile Picture
    OrenLevy 21 on at
    Re: HTTP request with Bearer Token

    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:

    •  I consume the webhook payload (json).
    • Convert it to a string.
    • Add a json wrapper around it to include the source of the webhook ("disp" parameter)
    • Create an HTTP post response and sends that to Power Automate.

    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);
     
     }

     

     

  • divdivsays Profile Picture
    divdivsays 3 on at
    Re: HTTP request with Bearer Token

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,636

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,942

Leaderboard

Featured topics