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 / Returning sharepoint s...
Power Automate
Answered

Returning sharepoint search results to powerapps from flow

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I would like to be able to call the sharepoint search rest api  from my powerapps using flow.

 

I have a  standalone app that displays data from a list with many fields in a gallery. I want to be able to filter the items in the list based on a sharepoint search query. (i.e. I want to be able to let the user enter CustomerName=Contos* and have the view show only records where the field CustomerName  begins with ‘Contos’.

The powerapps search function works, but it queries all fields. I want to query on Specific fields using the search API.

I want to be able to call a flow, passing in the search query string ‘CustomerName=Contos*’  and the list of fields to return, and have the flow  call the sharepoint search API (_api/search/postquery)  and return the data in tabular format so that the gallery control can just switch between using list data and search results.

 

I  got it working by looping through all the results in @body('SPSearch')?['d']?['postquery']?['PrimaryQueryResult']?['RelevantResults']?['Table']?['Rows']?['results'] and then for each row looping through all of the columns and setting a temporary field to the value for that column, but it takes 10 minutes to run a simple query (because of the work being done in the for loop).

 

The issue is that the results from search look like this:

"results": [

    {

      "__metadata": {

        "type": "SP.SimpleDataRow"

      },

      "Cells": {

        "results": [

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Rank",

            "Value": "27.591251373291",

            "ValueType": "Edm.Double"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "DocId",

            "Value": "17594549904503",

            "ValueType": "Edm.Int64"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Title",

            "Value": "TiO2_BCN - GR Nanomaterials - V. Mathur",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ListItemID",

            "Value": "5678",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Created",

            "Value": "2014-06-27T14:46:49.0000000Z",

            "ValueType": "Edm.DateTime"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "IsClosedOWSCHCS",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ContactEmailAddressOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "CompanyOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RequestTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResponseTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "_ranking_features_",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "PartitionId",

            "Value": "9eec07e6-f6f8-4e24-b4c7-c5868500b417",

            "ValueType": "Edm.Guid"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "UrlZone",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Culture",

            "Value": "en-US",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResultTypeId",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RenderTemplateId",

            "Value": "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js",

            "ValueType": "Edm.String"

          }

        ]

      }

    },

    {

      "__metadata": {

        "type": "SP.SimpleDataRow"

      },

      "Cells": {

        "results": [

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Rank",

            "Value": "27.5383605957031",

            "ValueType": "Edm.Double"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "DocId",

            "Value": "17621262638504",

            "ValueType": "Edm.Int64"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Title",

            "Value": "Prochazka, Jan ADVANCED MATERIALS JTJ",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ListItemID",

            "Value": "26",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Created",

            "Value": "2011-02-21T22:12:36.0000000Z",

            "ValueType": "Edm.DateTime"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "IsClosedOWSCHCS",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ContactEmailAddressOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "CompanyOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RequestTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResponseTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "_ranking_features_",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "PartitionId",

            "Value": "9eec07e6-f6f8-4e24-b4c7-c5868500b417",

            "ValueType": "Edm.Guid"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "UrlZone",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Culture",

            "Value": "en-US",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResultTypeId",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RenderTemplateId",

            "Value": "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js",

            "ValueType": "Edm.String"

          }

        ]

      }

 

  ]

 

Anyone have any ideas how to turn the search results in the above  format into a regular ‘flat’  array  so that it can be returned to powerapps?

 

 

 

 

Categories:
  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I just found that search DOES let me choose which column to search . Still would be valuable to use SP search engine for more complex searches though and would help avoid delegation issues.

  • v-bacao-msft Profile Picture
    Microsoft Employee on at

     

    Hi @Anonymous ,

     

    Have you found a suitable solution? If so, please click "Accept as Solution" on the reply that describes how describes you were able to solve your issue!

    In addition, perhaps you could try to use the action Parse JSON-Filter array to achieve the need to filter the array.

    Please check this article and see if it helps:

    http://johnliu.net/blog/2018/6/a-thesis-on-the-parse-json-action-in-microsoft-flow

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey, Someone figured out how to do this and posted the solution at https://buildbod.com/2018/10/29/sharepoint-search-results-as-a-csv-file-using-microsoft-flow/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 259 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 227 Super User 2026 Season 2

#3
Valantis Profile Picture

Valantis 134 Super User 2026 Season 2

Last 30 days Overall leaderboard