web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / HTTP request to Sharep...
Power Automate
Unanswered

HTTP request to Sharepoint sharing link fails with 401-unauthorized

(0) ShareShare
ReportReport
Posted on by 2

Hi there,

 

I would like to access a sharepoint file behind a sharing link from a flow, so that I can fetch and send them as e-mail attachments later. The problem is that if I try to make a HTTP request to the sharing link, it always returns 401-UNAUTHORIZED.

 

The Site address I use is a Onedrive for Business address, the URL is the sharing link:

KKuntner_1-1678915222605.png

 

I looked into how the sharing linkg resolution works from the browser, it should return a 302 REDIRECT, and point to the actual resource. The only way I was able to produce the 302 response from the flow was when I entered a Cookie header with the rtFA and FedAuth cookies copied from my browser session. But that is not a solution...

 

I even tried Azure AD HTTP Request, but it failed the very same way.  

 

I have set the connection up correctly, all other sharepoint actions are working without any issues. I just don't understand why I get 401? Help me understand and resolve please 🙂

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @KKuntner,

     

    Is this an anonymous sharing link?

     

    If so, you could potentially use a HTTP action instead. Directly after the HTTP you can use a Send an HTTP request action. Make sure you use the configure run after has failed status in the settings of that second action. This way it will continue when it gets the HTTP 302 failed response.

     

    Within the URI of that second action you can use the Location value of the outputs Headers of the HTTP action.

     

    That value can be used in a GetFileById method, described by Arjun Menon in this nice article:

    https://arjunumenon.com/get-doclibraryname-uniqueid-RESTAPI/

     

     

    Below is an example

     

    1. HTTP action with the full sharing link

     

    2. Send an HTTP request action

    a. configure run after in settings to only has failed

    b. Use the following expression in the URI

     

    _api/web/GetFileById('@{substring(outputs('HTTP')['headers']['Location'], add(indexOf(outputs('HTTP')['headers']['Location'], 'sourcedoc=%7B'), 13), 36)}')

     

     

    anonymouslink_redirect.png

  • KKuntner Profile Picture
    2 on at

    Hi @Expiscornovus  - Thanks for your reply and direction, but unfortunately no, it is not an anonymous link, works for "People within the company only". So we do need the authentication round before 😞

     

    I tried the plain HTTP action too, but obviously it failed (but succeeded when I passed the cookies).

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard