SharePoint Search API
3 TopicsSharePoint Search results to CSV
I have a use case where I want end-users to be able to use SharePoint Search to perform searches and then export those search results to a CSV file. I found many examples online explaining how to translate the criteria the user enters into the Search Search textbox into an API request. My problem, however, is that those examples often fail when the user clicks one or more of the left-hand refiners because the new resultset is often a combination of the user's querytext and the left-hand refiners they select. The UX I am hoping for is: User goes to the SharePoint Search page. Performs a search. Refines the results using the left-hand refiners. Clicks "Export results to Excel". I am a software developer, so I can develop almost anything we need (i.e. embed javascript on the page, build proxy APIs, etc.). I just need some advice on capturing the querytext AND refiners the end-user selected on the SharePoint Search page so I can replay that same query to the SharePoint Search APIs to eventually generate the CSV extract I am looking for. So far, I've tried capturing the query from the URL. https://sharepoint2019.domain.local/search/Pages/results.aspx?k=smith&ql=1033#Default=%7B%22k%22%3A%22smith%22%2C%22r%22%3A%5B%7B%22n%22%3A%22FileType%22%2C%22t%22%3A%5B%22equals(%5C%22odp%5C%22)%22%2C%22equals(%5C%22ppt%5C%22)%22%2C%22equals(%5C%22pptm%5C%22)%22%2C%22equals(%5C%22pptx%5C%22)%22%2C%22equals(%5C%22potm%5C%22)%22%2C%22equals(%5C%22potx%5C%22)%22%2C%22equals(%5C%22ppam%5C%22)%22%2C%22equals(%5C%22ppsm%5C%22)%22%2C%22equals(%5C%22ppsx%5C%22)%22%5D%2C%22o%22%3A%22or%22%2C%22k%22%3Afalse%2C%22m%22%3Anull%7D%5D%2C%22l%22%3A1033%7D When I decode Default below is what I get, which appears to have the user's text input and the refiners they've selected: { "k": "smith", "r": [ { "n": "FileType", "t": [ "equals(\"odp\")", "equals(\"ppt\")", "equals(\"pptm\")", "equals(\"pptx\")", "equals(\"potm\")", "equals(\"potx\")", "equals(\"ppam\")", "equals(\"ppsm\")", "equals(\"ppsx\")" ], "o": "or", "k": false, "m": null } ], "l": 1033 } My problem is that I can't find a way or API to which I can send this payload that will perform the same search against the SharePoint Search APIs (which I intend to use in a proxy API to generate the CSV in the desired format). If I am going about this wrong, I'm happy to scrap this approach and perform the search another way. The important thing, however, is that the user needs to perform the search via the SharePoint Search page. They must also be able to use the left-hand refiners to refine their results further. Any ideas on achieving the desired outcome would be much appreciated. This is for a SharePoint 2019 on-premise installation.709Views0likes0CommentsHow to use SharePoint search query with SharePoint Granular access permissions?
I want to execute SharePoint search API with granular access for that I've changed 'Sites.ReadWrite.All' permission to 'Sites.Selected' permission, so that application would have all sites access but during search I'm getting unauthorize error ``` {"odata.error":{"code":"-1, Microsoft.Office.Server.Search.REST.SearchServiceException","message":{"lang":"en-US","value":"Unauthorized."}}} ``` Also tried to give sites.selected permission at tenant level, that also not works, if the only solution is to give 'Sites.ReadWrite.All' or 'Sites.Read' then there is no use of granular level access implementation Sites.Read.all will allow all sites if granted. My query is similar to below -: https://tenant.sharepoint.com/_api/search/query?querytext='*+AND+(Path:"https://tenant.sharepoint.com/sites/SITE1/RECORDS" OR Path:"https://tenant.sharepoint.com/sites/SITE2/RECORDS")'&trimDuplicates=false&selectProperties='Column1,Column2'&refiners='Column1OWSTEXT'&refinementFilters='Column1:equals(\"xxxxx\")'&rowLimit=5 Some other references regarding my question. https://sharepoint.stackexchange.com/questions/306397/how-to-use-sharepoint-search-query-with-sharepoint-granular-access-permissions?newreg=dbcbb62ae019481c9a864f537ecd0faf https://sharepoint.stackexchange.com/questions/306432/is-that-sites-selected-permissions-level-allows-the-sharepoint-online-global Really appreciate any response on this or alternative approach to to achieve this.747Views0likes0CommentsSharePoint Search API result returns unexpected RowCount
Hi I am struggling to understand why the following request https://%xyz%.sharepoint.com/_api/search/query?querytext='marco'&rowsperpage=10&rowlimit=200&clienttype='ContentSearchRegular' Results in a row count of 2 whereas https://%xyz%.sharepoint.com/_api/search/query?querytext='marco'&startrow=1&rowsperpage=10&rowlimit=200&clienttype='ContentSearchRegular' Results in the expected row count of 10 Initially the first query worked fine (since 2017) and the unexpected result is new. Therefore I believe it may be related to an update by Microsoft. Curious to see if anyone else is experiencing the same thing! PS What is also odd is that for other queries e.g. 'sharepoint' I get immediately 10 rows of results.1KViews0likes0Comments