How to ignore OneDrive Files in Sharepoint files search? - sharepoint

I'm trying to search Sharepoint & Teams files through POST https://graph.microsoft.com/v1.0/search/query. I passed the entityType as listItem in the request body so that I could able to search Sharepoint, Teams & Onedrive files.
But in my case, I should ignore the files from Onedrive.
Is there a way to filter OneDrive files & search only Sharepoint & Teams files?

The url of OneDrive files starts with https://contoso-my.sharepoint.com/, and the url of SharePoint files starts with https://contoso.sharepoint.com/.
So you could add filter in th query like this to ignore Onedrive files:
path:\"https://contoso.sharepoint.com/*\\"
Reference: https://learn.microsoft.com/en-us/graph/search-concept-files#example-5-use-filters-in-search-queries
https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference

Related

Does SharePoint API offer an endpoint for doing a full text search on the content of the documents?

I am using SharePoint as a DMS for my app.
Via the SharePoint API I am uploading, and downloading files, and retrieving folders and files.
I have been using the standard url blueprint:
https://{{TenantName}}.sharepoint.com/sites/{{SiteName}}/_api/web/...
I need to add a full text search in the app. I need to be able to send a queryString parameter to the API, and to get returned all files that contain that string. Not in their name, but in their content.
Is that even possible? Could not find it online. Any help is greatly appreciated.
As far as I know, you can use the following REST API to search in SharePoint:
GET http://{server}/_api/search/query?querytext='sharepoint'
I suggest you can refer to this document: SharePoint Search REST API overview
Hope it can help you.

How to get Word document properties using PowerAutomate when the file is uploaded to SharePoint

I have a SharePoint site document library that I'll be uploading Word documents to. When the Word document is uploaded to SharePoint I would like a PowerAutomate flow to be triggered that would collect the Word document's properties (such as Authors, Last saved by, Company etc). I have tried creating flows using SharePoints 'Get Files'. 'Get file metadata' and 'Get file properties' but they are only retrieving data from when after the file is uploaded and not file properties from the actual file when it is initially uploaded. Any advice would be much appreciated.

Sharepoint Graph API download file from Document library that are not listed as drive ("Site Pages" and others)

I'm trying to find a way in Sharepoint Graph API how download file in Document library that are not listed as drive (Site Pages and others).
If I enumerating lists, I see "Site Pages" in lists:
https://graph.microsoft.com/v1.0/sites/<site id>/lists
I even can enumerate item in list :
https://graph.microsoft.com/v1.0/sites/<site id>/lists/<list id>/items
But I can't find a way to get a content (download) those items (files).
All available url to download file (get content) are next:
GET /drives/{drive-id}/items/{item-id}/content
GET /groups/{group-id}/drive/items/{item-id}/content
GET /me/drive/root:/{item-path}:/content
GET /me/drive/items/{item-id}/content
GET /sites/{siteId}/drive/items/{item-id}/content
GET /users/{userId}/drive/items/{item-id}/content
Doesn't provides an ability to get the content.
I can't find a way to get drive id for list, and there's no url to get content from list (even if it's documents library).
Please advise.
Thanks
You can call the following endpoints to retrieve:
all document libraries on a site
items in a document library (from root)
download the content of an item
This may not be the most efficient set of queries but I successfully tested in my lab tenant.
https://graph.microsoft.com/(version)/sites/(site-id)/drives
https://graph.microsoft.com/(version)/sites/(site-id)/drive/(drive-id)/root/children
https://graph.microsoft.com/(version)/sites/(site-id)/drive/(drive-id)/items/(item-id)/content
The drive resource represents a user's OneDrive or a document library in SharePoint. while site page is a page library, not document library, this is why it's not returned in drive request.
We suggest you get the file using SharePoint Rest API.
Working with files by using REST

Sharepoint 2013 file copy

I have a requirement.when a file is uploaded to document library,if a PDF file is uploaded then it should be routed to another Site collection’s library.with the help of OOTB or workflows or rest calls or CSOM.
Please let me know if any body worked on this type of problem.
You can create one event receiver, so when an item is added in a list you can check its extension.If it is a pdf file then you can write a code to copy that file to the desired location in another site collection and after successful copy ,you can delete that file.

Clear connections to SharePoint in Word Document

We are having issues with word connecting to SharePoint to retrieve data even if we've downloaded a document from the site.
Here is how our process is setup
We work with documents and prepare them on the workspace
When done a publishing workflow copies the documents using SPFileCollection.Add(string urlOfFile, byte[] file, bool overwrite), http://msdn.microsoft.com/en-us/library/ms428630.aspx
The issue is when opening documents either directly from the published documents site collection or even if we download them to disk the word goes to the workspace site to fetch data (Word Phone Home).
This issue is related with the post linked below but I want to break the "phone home" behavior.
https://sharepoint.stackexchange.com/questions/19390/what-is-slowing-the-opening-of-office-documents

Resources