Search for Content Across SharePoint Sites - sharepoint

Currently I'm using: /v1.0/sites/{site-id}/drive/root/search(q='{search-text}') but I would like to search across all the sites I have access to.
Is there a Microsoft Graph API which can search a keyword on all sites a user can access in SharePoint without giving site id?

There's no Graph API for a global content search at the moment.
However you can leverage the SharePoint Search API.

Related

How to get Sharepoint site members with Microsoft Graph API?

I am building an app which checks which member has access to which Sharepoint sites. How do I do that with the Microsoft Graph API?
For OneDrive I can get the user's drives by
graphServiceClient.Users[memberId].Drive.Root.Children.Request()
I would like to do that with Sharepoint sites like this
graphServiceClient.Users[memberId].Sites.Root.Children.Request()
but that is not possible. Any idea waht is the right API to get the all the Sharepoint sites the user have access to?

Microsoft Graph API - How to Filter SharePoint sites by Site Type?

SharePoint Admins in Microsoft 365 can create Team Sites and Communication Sites using the admin center.
In addition, individual users can have Personal Sites (Otherwise known as My Sites)
Using the Microsoft Graph .NET SDK I can retrieve all sites like this:-
await client.Sites.Request().GetAsync();
However this appears to include all Team, Personal and Communication Sites. Is there a way to limit the request to only one type of site, or detect the type of each site returned from the query? I could not find anything in the documentation about this.
Edit: If there's a way to get this information via SharePoint CSOM, I would be interested in that too
Unfortunately this is not available as of now but there is a uservoice already raised. Please upvote it so that this feature may be implemented in the future.
I don't know if it can help you but I found a workaround how to differentiate between a team/communication site and a personal site.
A personal site contains in the WebUrl field the string "my.sharepoint.com/personal/", then after you make the call: var sites = await client.Sites.Request().GetAsync(); you can use this filter to retrieve only personal site: var personalSites = sites.Where(s => s.WebUrl.Contains("my.sharepoint.com/personal/")); (Microsoft does not allow to use a filter on this request directly, so this is the reason why I used the filter after fetching all sites.)

Need help on searching a document form Sitepage in Sharepoint using Microsoft Graph

I am working on SharePoint Integration where i am able to success using Microsoft Graph Explorer for a Site search using Drive id.
Here is how i am able search for a Single Site:
https://graph.microsoft.com/v1.0/drives/b!I9A-JY94D0CQp-2TBvsUupBLMUF2SrJHp5VylC7DY8DpCdF-7uQ6NTp6t-MRD8/root/search(q='sharepoint')
With this i am able to get the details of the record 'Sharepoint'.
Now i am trying to search in SitePage where we have Documents added. Can anyone please help me the api to be used in Graph Explorer to get the correct result
I am able to SitePage id using
https://graph.microsoft.com/beta/sites/root/pages?$filter=name eq 'DevHome.aspx'
Your Approach is incorrect.
If you have to search the content of the document library added to a Site page, you need to query the doc library not the Site page.
Using Graph API you will not be able to search the content in the site page.

How do I get started from reading SharePoint list information from outside of SharePoint?

We have a SharePoint subscription and an Azure subscription. I want to make a web app that is hosted in Azure, but the database for the app would basically be SharePoint lists. I'm looking up documentation on how to do this, but I'm just finding how to make "web parts" and they keep assuming I want to build my website inside SharePoint rather than outside.
How do I access a user's SharePoint lists from outside of SharePoint?
The easy part is the request for data. Use the SharePoint REST API. The harder part is authentication. How is the Azure app related to the SharePoint app? Same user login?
A sample REST call for select columns from a list:
https://yourDoamin/sites/yourSite/_api/web/lists/getbytitle('My List')/items?$select=Title,Price,Qty
The REST API also support filtering and sorting along with insert, update and delete.
A filter example:
https://yourDoamin/sites/yourSite/_api/web/lists/getbytitle('My List')/items?$select=Title,Price,Qty&$filter=Title eq 'Toys'
If you would like to experiment with the REST API from your SharePoint site, I have "REST tester" you can add to a Content Editor Web Part.
https://github.com/microsmith/SharePointRESTtester

Microsoft Graph API - Search content over a sharepoint site

We are creating a Sharepoint webpart that enable searching a Sharepoint site contents using Microsoft Graph Api. I am able to get the Lists and subsites
using graph Api, but not sure how to search any content at site level.
Looking for any pointers if this is even achievable.
Below are some of the API calls that work-
https://graph.microsoft.com/v1.0/sites/tenants/lists?select=id,name
https://graph.microsoft.com/v1.0/sites/tenants:/sites/sitename:/sites?search=subsitename
https://graph.microsoft.com/v1.0/sites/tenants:/sites/sitecollection:/lists
here is an example filtering on a list items
https://graph.microsoft.com/v1.0/sites/myThing.sharepoint.com,ffffffff-ffff-ffff-ffff-ffffffffffff,12345678-1234-1234-1234-123456789012/lists/25dd5a71-69a9-44f8-b60f-ed16718eae54/items?expand=fields(select%3DTitle,ID,ContentType,myLookupID)&top=1000&filter=fields/ContentType eq 'My Page'

Resources