Check whether SharePoint Online URL is valid document library or not - sharepoint

I have a software where users of office 365 tenancy will copy / paste any url to the software and I need verify / correct that URL to a proper document library.
For example;
https://contoso.sharepoint.com/Projects/Current/Forms/AllItems.aspx
should automatically be corrected to
https://contoso.sharepoint.com/Projects/Current/
And if user types;
https://contoso.sharepoint.com/Lists/Task (Task list and NOT the library)
I should throw error saying its NOT a valid document library.
There are really lots of combination of URL to it. I can use Graph API / REST API (But NOT c# as its in PHP). I am really not able to fetch any API which can do this for me.
Any suggestion?

You could try sharepoint rest api :
https://xxxx.sharepoint.com/sites/team/_api/web/GetFolderByServerRelativeUrl('Lists/Example')/Properties
You could find the vti_x005f_listservertemplate property . it's a generic list if the value is 100 . and if value is 101, it's a Document Library .

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.

Is it possible through the REST api to retreive which sites a specific user is following in Sharepoint?

Using the SharePoint REST api or search API, is it possible to retrieve a full list of all the sites a specific user is following? All I can find in the documentation is https://<sharepoint>/_api/social.following/my/followed(types=4) which only works for the current logged in user.
I don't think this is possible. The below are the only available endpoints:
Follow
StopFollowing
IsFollowed
My
My/FollowedDocumentsUri
My/FollowedSitesUri
My/Followed
My/FollowedCount
My/Followers
My/Suggestions
GetMySuggestions
IsMyPeopleListPublic
AmIFollowedBy
GetPeopleFollowedBy
GetFollowersFor
Reference

Using Microsoft Graph API to Query Certain Sharepoint URIs with .aspx Extensions

I have a question about sharepoint combined with the graph API. I'm trying to do a GET request against a sharepoint site, but it doesn't populate when the url has a .aspx extension. For example if I do 'GET https://graph.microsoft.com/v1.0/sites/hostname.sharepoint.com:/sites/blablabla/UK' this populates a response fine, but if I do 'GET https://graph.microsoft.com/v1.0/sites/hostname.sharepoint.com:/sites/blablabla/UKDTAppKZ/something.aspx' then I get a 404 error suggesting this site doesn't exist... Could I get some clarification on how to use graph GET queries with sharepoint urls, specifically .aspx extensions?
In your first URL you're accessing the Site object for the /sites/blablabla/UK sub site, so you should get back a valid site object (assuming the URL is correct) as you indicated. To access the files in that site you need to access the Drives (Document Libraries) and then get the children or the specific item you're looking for. So the URL would look something like:
Path support isn't always consistent right now so wherever possible I like to use IDs if I know them.
So with an ID it would be:
https://graph.microsoft.com/v1.0/sites/HOSTNAME.sharepoint.com,SITECOLLECTIONGUID,SITEGUID/drives/DRIVEID/root/children
OR
https://graph.microsoft.com/v1.0/sites/HOSTNAME.sharepoint.com,SITECOLLECTIONGUID,SITEGUID/drives/DRIVEID/items/ITEMID
For Pages specifically though I would take a look at the Beta Pages API we added recently. If you want to do any operations (like publishing) to the page you'll want that API instead of the basic drive API.

Access files of Document Library site through Microsoft Graph API

I was wondering if the two following queries are actually the same or supposed to be the same:
GET https://graph.microsoft.com/beta/sharepoint/sites/{spsite-id},{spweb-id}/drives
and
GET https://graph.microsoft.com/beta/sharepoint/sites:/MYPATH:/drives
I would like to access a Document Library Item in a sharepoint site through the relative path.
Please mind that both endpoints below are the same for getting all doc libraries or drive in a site according to the current beta microsoft graph documentation. The latter becomes handy when you dont know the site id yet but the relative site url.
https://graph.microsoft.com/beta/sites/[domain.sharepoint.com]:/[relative-url]:/drives
https://graph.microsoft.com/beta/sites/[site-id]/drives
(e.g. site id: "cie493742.sharepoint.com,4af352a7-a53b-43d9-b0a3-da372b392ea0,52c490f3-3354-40b9-a3c9-fefb08cb5c88" )
Now to get the document library item
Get Document library id from list of drives
https://graph.microsoft.com/beta/sites/[site-id]/drives
Get item id from list of items
https://graph.microsoft.com/beta/sites/[site-id]/drives/[drive-id]/items
Final API call
https://graph.microsoft.com/beta/sites/[site-id]/drives/[drive-id]/items/[item-id]
you could try experimenting the Graph API from here

Office 365 Unified API Exchange folders

I'm starting to look at the new Office 365 Unified API (specifically around Exchange for the moment).
In the existing Mail API at you can make an authenticated call to https://outlook.office365.com/api/v1.0/me/folders/Inbox/messages in order to get messages in the Inbox. You can also hit folders/Drafts/messages, folders/SentItems/messages and folders/DeletedItems/messages to retrieve messages from Drafts, Sent Items and Deleted Items respectively. This is documented at https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#AllMailAPIoperations.
Problem is, I can't find (either in documentation at https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_relationship_Messages or by messing about on https://graphexplorer2.azurewebsites.net) how to drill into these folders when accessing via the Office 365 Unified API.
The documented URL to access messages via the new Unified API is https://graph.microsoft.com/beta/me/Messages, and so I was hoping I could hit something like Messages/Inbox or Messages/folders/Inbox, but no luck so far.
Does anyone know if these paths are currently missing or addressed differently, or if it's the intention that you find what you want by using $search rather than drilling into specific folders?
This isn't currently supported in Unified API, but is high on our priority list, and we are working on it. Sorry for the confusion. You can continue to use outlook.office365.com endpoint for now, to access folder info.
Having checked back (and read through https://graph.microsoft.com/beta/$metadata) this has now been implemented. You access folders via MailFolders/[folder name]/messages, so:
https://graph.microsoft.com/beta/me/MailFolders/Inbox/messages
https://graph.microsoft.com/beta/me/MailFolders/Drafts/messages
https://graph.microsoft.com/beta/me/MailFolders/SentItems/messages
..etc.

Resources