Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Copilot Studio - General
Unanswered

Sharepoint Rest api with HTTP request Action in Copilot Studio

(0) ShareShare
ReportReport
Posted on by 4
I am creating copilot with the Authenticate with Microsoft(Entra ID authentication in Microsoft Teams, Power Apps, or Microsoft 365 Copilot) options.
I want to make a http request to the sharepoint site with the urls https://tenant.sharepoint.com/sites/sales/_api/web/lists/getbytitle('Tickets')/items
I am using the HTTP Request Action to do the rest api to sharepoint, but I am getting error
 Error Message: HTTP request failed with status code 403 Forbidden. Error Code: HttpRequestFailure Conversation Id: a32da511-319e-4067-98b6-d6ae5d95494d Time (UTC): 2024-12-19T12:11:57.067Z
 
I hope this is related to Authentication issue but to add the Authorization in the header I am not getting the  System.User.AccessToken  variable. Can Anyone help how can I authenticate the request. ?
 
Any ideas/reference links/ documentation links are highly helpful.
Thanks in Advance
 
 
Categories:
  • TD-19121201-0 Profile Picture
    TD-19121201-0 4 on at
    Sharepoint Rest api with HTTP request Action in Copilot Studio
    @SaiRT14 Thanks for the response. If we use the your approach, The search api will not work with the user context, means it will return all the items from the sharepoint, but i need the results as per the user permission. Is there any way to get the results as per the user permission on the site and list items using the access token approach. 
  • SaiRT14 Profile Picture
    SaiRT14 1,941 Super User 2025 Season 1 on at
    Sharepoint Rest api with HTTP request Action in Copilot Studio
    The 403 Forbidden error typically occurs because the request to SharePoint does not have sufficient authentication or permissions to access the resource. 
     
    Ensure that your app (Copilot, Power Automate, or Teams app) has permissions to authenticate to SharePoint using Azure Active Directory. Verify that the System.User.AccessToken variable is enabled in your flow or app. To enable this: Open the HTTP action in Power Automate. Under Settings (gear icon), enable the Secure Inputs and Outputs option. Ensure the connection is authenticated with Azure AD.
     

    If System.User.AccessToken is not available, you can retrieve an access token manually using the following steps:

    • Create an Azure AD App Registration: Go to Azure Portal → App Registrations → New Registration. Provide a name, and under Supported account types, select "Accounts in this organizational directory only." Note the Application (Client) ID and Directory (Tenant) ID.

    • Assign API Permissions: Go to the app's API permissions. Add permissions for SharePoint (Sites.Read.All, Sites.Manage.All, or other relevant permissions). Grant admin consent.

    • Generate a Client Secret: Go to the app's Certificates & Secrets. Create a new client secret and note the secret value.

    • Obtain the Access Token: Use the following HTTP request in Power Automate or a custom script to get the access token. 

      POST https://login.microsoftonline.com/{Tenant-ID}/oauth2/v2.0/token
      Content-Type: application/x-www-form-urlencoded
      grant_type=client_credentials
      client_id={Application-ID}
      client_secret={Client-Secret}
      scope=https://{Tenant}.sharepoint.com/.default
       
    • Use the retrieved token in the Authorization header of your SharePoint request:  Authorization: Bearer {Access-Token}
       

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 146,318 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,111 Most Valuable Professional

Leaderboard