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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Search Sharepoint usin...
Power Automate
Answered

Search Sharepoint using HTTP Request

(2) ShareShare
ReportReport
Posted on by 240
Hello,
 
i have a App that is mainly built on Dataverse, it is used by two User Groups (2 Sub Companies).
In Dataverse they all Access the same Data, but i also do Some document Creation and viewing using SharePoint-Connection with this App.
Till now this has been done only from one User Group, so everything was easy i added the SharePoint Connection and used it to search and Display Documents (usually PDF)
 
my first approach was to add a switch prior Document connector, so if user is in Company A acces Documents (first sharepoint connection), if he is in Company B, access Documents_1 (Second sharepoint)..
unfortunately this is not working (even though the Document Library would be structured identically)
i really don't want to create separated App Screens or even Apps for the users, as they all do the same.
 
so i wanted to create a Flow that pulls the Data from SharePoint, searching in both SharePoints and giving this back to PowerApps
 
My Document Librarys have a Custom Column Called 'Info' the data i need to retrieve has Text in this Info Column, so i wanted to use this http request:

_api/web/lists/getbytitle('Dokumente')/items?$filter=Info ne null
 
without success - i do get data but not the correct ohne, the files that are displayed have no value in the Info Column.
 
using get files (Properties only) would work, but takes ages to load, so i wanted to solve it with a HTTP request, as i assume this is faster.
 
can anyone help me setting up a working HTTP request?
 
thanks!
Categories:
I have the same question (0)
  • Suggested answer
    Hamza Khalid Profile Picture
    77 on at

    Hey there!

    It sounds like you're in a bit of a pickle with your Power App and SharePoint connections, especially trying to keep things speedy and user-friendly for both your sub-companies. It's awesome that you're aiming for a single app experience!

    That "switch prior Document connector" idea for different SharePoint connections is definitely a common first thought, but as you've found, it doesn't always play nice. And you're spot on—using Power Automate (Flow) for a direct HTTP request to SharePoint is usually the way to go for better performance, especially when you need to filter data efficiently.

    Let's dive into why your current HTTP request might be a bit off and how to get it humming!

    The Sneaky Culprit: SharePoint Column Internal Names

    You're using _api/web/lists/getbytitle('Dokumente')/items?$filter=Info ne null, which should work for a "not null" filter. However, the most frequent reason this goes awry is because of SharePoint column names. When you create a column with a friendly display name like "Info," SharePoint often assigns it a slightly different internal name behind the scenes. And for REST API queries, you must use that internal name.

    Sometimes, SharePoint might append numbers (like Info0) or adjust the name if you've had columns with similar names before.

    How to Find the True Internal Name

    This is super important! Here's how you can dig it up:

    1. Navigate to your 'Dokumente' document library in SharePoint.

    2. Click on the gear icon (⚙️) in the top right, then select "Library settings."

    3. Under the "Columns" section, click directly on your "Info" column.

    4. Now, look at the URL in your browser's address bar. You'll see something like .../Lists/Dokumente/Settings.aspx?Field=YourInternalColumnName. That string right after Field= is your column's internal name.

      For example, if the URL shows Field=Info0, then Info0 is the internal name you need to use.

    Crafting the Perfect HTTP Request

    Once you have that exact internal name (let's call it YourInfoInternalName for now), you'll plug it into your query:

    _api/web/lists/getbytitle('Dokumente')/items?$filter=YourInfoInternalName ne null

    Boosting Performance Even More with $select

    To make things lightning fast, tell SharePoint exactly which columns you want back. This reduces the amount of data transferred. If you only need the document's Title, its FileRef (for the direct link), and your Info column, your request would look like this:

    _api/web/lists/getbytitle('Dokumente')/items?$select=Title,FileRef,YourInfoInternalName&$filter=YourInfoInternalName ne null

    Setting Up Your Power Automate Flow (The Better Way!)

    Here’s a breakdown of how to structure your flow to handle both companies efficiently:

    1. PowerApps (V2) Trigger: Start with this. Add an input for CompanyName (Text) so your Power App can tell the flow which company's SharePoint to hit.

    2. Condition Action:

      • Choose a value: Select CompanyName (from your PowerApps trigger).

      • Is equal to: Company A (or whatever you're using).

    3. Inside the 'If yes' branch (for Company A):

      • Action: Send an HTTP request to SharePoint

        • Site Address: Enter the base URL for Company A's SharePoint site (e.g., https://yourcompany.sharepoint.com/sites/CompanyASite).

        • Method: GET

        • Uri: _api/web/lists/getbytitle('Dokumente')/items?$select=Title,FileRef,YourInfoInternalName&$filter=YourInfoInternalName ne null

          • Crucial: Remember to swap YourInfoInternalName with the actual internal name you found earlier!

        • Headers:

          • Accept: application/json;odata=verbose

          • Content-Type: application/json;odata=verbose

    4. Inside the 'If no' branch (for Company B):

      • Action: Send an HTTP request to SharePoint

        • Site Address: Enter the base URL for Company B's SharePoint site (e.g., https://yourcompany.sharepoint.com/sites/CompanyBSite).

        • Method: GET

        • Uri: (Same as above, just ensure the correct internal name is used if it differs between libraries).

        • Headers: (Same as above)

    5. Action (After the condition, common to both paths): Parse JSON

      • Content: This is where you grab the results from your HTTP request. You'll likely use an expression like body('Send_an_HTTP_request_to_SharePoint')['d']['results'] (adjust the action name if you have multiple 'Send an HTTP request' actions).

      • Schema: The easiest way to get this is to run your flow once successfully with a good HTTP request. Then, copy the JSON output from the "Send an HTTP request" action, and in the Parse JSON action, click "Generate from sample" and paste your copied JSON. This creates the perfect schema.

    6. Action: Respond to a PowerApp or Flow (V2)

      • Add an output of type Array.

      • Name: DocumentData (or something similar).

      • Value: body('Parse_JSON') (this passes your parsed document data back to Power Apps).

    Bringing it All Together in Power Apps

    1. Add your Flow: In Power Apps, go to Data -> Add data -> Flows and connect your newly created flow.

    2. Call the Flow: When a user selects their company or when the app loads, call your flow:
      ClearCollect(colDocuments, YourFlowName.Run(YourCompanyNameVariable))
      Replace YourCompanyNameVariable with whatever you're using in your app to identify the user's company (e.g., from a dropdown, user profile, etc.).

    3. Display Your Documents: Now you can populate a Gallery control with colDocuments. Inside the gallery, you'll access the properties directly:

      • ThisItem.Title (for the document name)

      • ThisItem.FileRef (this is the full path, perfect for opening PDFs!)

      • ThisItem.YourInfoInternalName (to display the "Info" column content)

    Why HTTP Request Wins (Speed!)

    You're absolutely right to go for the HTTP request! The built-in "Get files (properties only)" action, while convenient, often does a lot more processing in the background. A direct HTTP request, especially when you use $select and $filter, talks straight to SharePoint's API. This means less data transferred and much faster load times for your users – exactly what you need when dealing with documents!

    Give this a shot, and let me know if you run into any specific errors or need more help tweaking that HTTP request. You're definitely on the right track!

    If you found this helpful, please mark this as the verified answer! It'll help others in the Power Platform community find this solution too.

  • TSte Profile Picture
    240 on at
    Thanks for your Fast Reply, 
    i have checked my Info Internal name, "unfortunately" it is Info, without anything added..
    i again tried this Request:
     
    now i am Getting BadGateway errors, but exactly this call did work today morning (just didnt filter as i wanted, but at least some data was pulled)
     
  • Hamza Khalid Profile Picture
    77 on at

    Okay, let's get this BadGateway error sorted out. It's frustrating when something that partially worked completely breaks! Since your 'Info' internal name is confirmed as 'Info', the filter itself (?$filter=Info ne null) is likely correct.

    A BadGateway usually points to a connection or server-side issue, not your filter syntax. Here's a concise troubleshooting guide:

    Troubleshooting BadGateway Errors

    1. Re-verify Site Address & List Name:

      • Site Address: Double-check the Site Address in your "Send an HTTP request to SharePoint" action. Make sure it's the exact base URL of your SharePoint site (e.g., https://yourcompany.sharepoint.com/sites/YourSiteName) with no typos or extra characters. Even a tiny error here can cause a BadGateway.

      • List Name: Confirm Dokumente is the exact display name of your document library (case-sensitive).

    1. Check Power Automate Connection & Permissions:

      • Connection Status: Go to "Data" -> "Connections" in Power Automate. Find your SharePoint connection. Does it show "Connected"? If not, try to fix or re-authenticate it.

      • User Permissions: Ensure the user account tied to this Power Automate connection has at least read permissions to that specific 'Dokumente' library on the SharePoint site. If the service account lacks access, the request will fail.

    1. Examine Flow Run History for Specific Errors:

      • This is crucial! Go to the run history of your flow and click on the failed run.

      • Expand the "Send an HTTP request to SharePoint" action.

      • Look at the "Outputs" section, specifically the body of the error. A BadGateway often wraps a more detailed error message from SharePoint itself, like "Access Denied," "List Not Found," or a specific correlation ID. This hidden message is key to understanding the root cause.

    The most common culprits for a sudden BadGateway after a partial success are incorrect Site Address, List Name, or a problem with the underlying SharePoint connection/permissions.

    Let me know what detailed error message you find in the flow's run history; that will tell us exactly what SharePoint is unhappy about!

  • Hamza Khalid Profile Picture
    77 on at
    Or you can try using postman to verify your api url. Sometimes due to credentials issue this happens. I had the similar experience for microsoft maps api few days back 
  • TSte Profile Picture
    240 on at
    hi,
     
    seems like using only _api/web/lists/getbytitle('Dokumente')/items?$filter=Info ne null gives to many results..
          "errors": [
            "-2147024860",
            "Microsoft.SharePoint.SPQueryThrottledException"
          ]

    i don't know the exact Amount of files that should be found, but i guess it will be something like 1000-2000,
    The folder Structure in 'Dokumente' is quiet big.
    but i would only have to search in one specific folder, with something like 150 subfolders.
     
    maybe this information helps :)
  • Verified answer
    Hamza Khalid Profile Picture
    77 on at

    Got it, the SPQueryThrottledException means you're hitting SharePoint's limits! Your _api/web/lists/getbytitle('Dokumente')/items?$filter=Info ne null query is trying to pull too much data at once.

    Since you need to search a specific folder and its subfolders, the best approach is a CAML query via a POST request in Power Automate. This method is designed for large lists and recursive searches without throttling.

    Here's the essential part for your Power Automate "Send an HTTP request to SharePoint" action:

    • Method: POST

    • Uri: _api/web/lists/getbytitle('Dokumente')/GetItems

    • Headers:

      • Accept: application/json;odata=verbose

      • Content-Type: application/json;odata=verbose

    • Body (JSON):

    {
    "query": {
    "__metadata": { "type": "SP.CamlQuery" },
    "ViewXml": "<View Scope='RecursiveAll'><Query><Where><And><IsNotNull><FieldRef Name='Info'/></IsNotNull><Eq><FieldRef Name='FSObjType' /><Value Type='int'>0</Value></Eq></And></Where></Query></View>",
    "FolderServerRelativeUrl": "/sites/YourSiteName/Dokumente/YourSpecificFolderName"
    }
    }

  • TSte Profile Picture
    240 on at
    Unfortunately no change, still exceeding List Limit :(
  • Hamza Khalid Profile Picture
    77 on at
    Try targeting any folder with 10 subfolder to check whether it's working for other folders or there is any other issue
  • Verified answer
    TSte Profile Picture
    240 on at
    Hi,
     
    i found a solution, i have made the Info column to an Index column! The document Library has 200k+ Files in it...

    now this works:

    {
      "query": {
        "__metadata": { "type": "SP.CamlQuery" },
        "ViewXml": "<View Scope='RecursiveAll'><Query><Where><And><IsNotNull><FieldRef Name='Info'/></IsNotNull><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq></And></Where></Query></View>",
        "FolderServerRelativeUrl": "/sites/mysite/Freigegebene Dokumente"
      }
    }
     
  • Hamza Khalid Profile Picture
    77 on at
    Please if you think I've helped you in solution mark my answer as verified solution

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard