Office Graph API sharepoint
2 TopicsMicrosoft Graph API Sharepoint Search
I have written an some python to send a request to the graph API to search a OneDrive for files containing keywords. def get_results(keywords, drive_id, next_url=None, total_results=[]): search_query = ' AND '.join(keywords) top = 500 # Set the desired number of results to retrieve select_properties = "id,name,createdDateTime" # Example properties to select if not next_url: base_search_url = f"https://graph.microsoft.com/v1.0/drives/{drive_id}/root/search(q=\'{search_query}\')" top_search = f"$top={top}" search_url = f"{base_search_url}?{top_search}" else: search_url = next_url headers = { 'Authorization': 'Bearer {}'.format(access_token), 'Content-Type': 'application/json' } response = requests.get(search_url, headers=headers) search_results = response.json() total_results += search_results.get('value', []) if '@odata.nextLink' in search_results: next_url = search_results['@odata.nextLink'] get_results(keywords, drive_id, next_url, total_results) return total_results However, when I run this, the result is that I get around 7k results, but I know for a fact there should be around 10k results. When I search the files in the OneDrive using body: keyword1 AND keyword2 I get all files returned, but with this method using the skip tokens, some files are not returned. On top of this, I also get duplicates, so if the 7k files, only 6k are unique. I'm not sure what I've done wrong with this method, I'm wondering if I could get some assistance on this. Thanks 🙂954Views0likes1CommentSearch through Sharepoint List Items via Graph API
I have a situation in which I would like to find a specific Folder inside a sharepoint environment. So the first steps are: Get User ID List Side ID List Side Items List Items (Shared Documents) > this call results in listing every single item available under Shared Documents, which can be hundreds up till thousands. How am I able to add a search query or any other filter on this? I tried with adding ?search={query} so it would look like /sites/{site-id}/lists/{list-id}/items?search={query} but once fired, the search is ignored. Anyone else knows how to do this as I was unable to find anything on the internet. I saw some things in relation to '?expand=' but I dont know how this works.3KViews0likes2Comments