Sharepoint Online DocumentSharing API - ms-office

trying to share a file with external users via the API, our in-house app will upload the file to sharepoint, return the view only link and we can then send that link to external users avoiding emails etc.
Is this possible with .NET C#?

Yes, it is possible. with the SharePoint client object model, your application can: Upload the document to the document list, and set the permission for that item, then return the link to external user.

Related

Allow only uploading files to SharePoint online programmatically

We're using a SharePoint online site as a backend repository for a web application. The web application has a UI to allow users to upload/download/view files using Graph API. That means the web application is registered as an Azure web application and is using users' delegated permission, so when a user uploads a file, we can see his/her username on the file at the SharePoint site.
Is there some way to disable users directly uploading files when they visit the SharePoint site and only allow the web site programmatically upload files on behalf of the user?
Using users' delegated permission means that you have implemented behalf of the user flow.
What you need currently is to disable users directly uploading files in SharePoint online site.
You have two options:
Hide the "Upload" button through CSS. But this method just hides an entry on the sharepoint website. In fact, users can still save a document directly from an Office Application to the Sharepoint library. I will not elaborate on it here.
The second method is to provide the user/group View Only Permission Level. You can see this post on StackExchange for details about how to restrict users to upload or add a new document by managing unique permission for your library.

addFileAttachmentAsync with SharePoint or Onedrive

I would like to attach a document from SharePoint Online to the mail with the office.js api.
The problem is that the addFileAttachmentAsync method just has an url as parameter so I can currently only attach public available files and not protected files.
In my app I can download the SharePoint file without a custom server as blob or base64.
Is it possible to use the html5 file api or can I reuse the SharePoint token somehow for addFileAttachmentAsync?
Currently there is no way to attach files that are not publicly available.

Which set of APIs should be used for Office365 Sharepoint

Which set of APIs should be use to access Office365 sharepoint which includes both sharepoint2013 and sharepoint2016.
Have gone through the following APIs
1) Sharepoint2013 REST APIs(https://msdn.microsoft.com/en-us/library/office/jj860569.aspx).
2) OneDrive new APIs(https://github.com/OneDrive/onedrive-api-docs) through which we can access the Directory folder which contains directory and files. But the present focus of APIs are for OneDrive Personal and Business.
Apart from this is there any other APIs which can access the office365 sharepoint?
You could use SharePoint REST API to retrieve, update, and manage data in Sharepoint Online ,you could find code samples and videos from here.
With Graph API you could get files/users/groups ,but SharePoint sites and lists are not yet available via Microsoft Graph .
In addition ,you could also use SharePoint client object model (CSOM) to manage data in Sharepoint Online,please read below article:
Connect to SharePoint Online using Client Object Model

accessing files and folders other than sharepoint site's default shared documents using office365 api

Working on windows store apps:
I am trying to access the files and folders of office365 documents library.
I can access the one drive documents as described in this link Common file tasks using the Office 365 client library
But it do not provide a way to access the files and folders in other than onedrive document library.
e.g [https://my-office365-tenant.sharepoint.com/mysite/mydocumentslibrary]
However i had tried a way and it do get the files and folders other than onedrive.
I had not used any capability i created SharePointClient as given below:
var client = new SharePointClient(new Uri("https://my-office365-tenant.sharepoint.com/mysite"),
async () => await AcquireTokenAsync(AuthenticationContext, "https://my-office365-tenant.sharepoint.com"));
IPagedCollection<IItem> items = await client.Files.ExecuteAsync();
In this way i get the files of default "Shared Documents" document library inside "mysite", but i want to get the files and folders of another documents library "mydocumentslibrary" inside same site "mysite".
Can anyone please guide me how to do that or am i missing something? or there is anyother way to do this using office365 api only.
I just went through the documentation of this new API, it seems the file operation is limited to the one drive, I doubt you can get file in another document library.
To get files in other document library, as you're developing windows store APPs, you can SharePoint mobile object model or REST APIs:
Overview of the SharePoint 2013 mobile object model
Get started withthe SharePoint 2013 REST service
The APIs allows access only to default document library. Example:
OneDrive for Business: https://{tenant}-my.sharepoint.com/_api/v1.0/me
SharePoint sites: https://{tenant}.sharepoint.com/{site-path}/_api/v1.0

How to make url for a document in document library publicly accessible?

I have Sharepoint 2010 hosted with windows authentication . I have created a document library inside a new site and uploaded few files.
Now,I'm trying to utilize the info of these files in some application using Rest Webservice exposed by sharepoint.
*http://{server_name}/{site}/_vti_bin/ListData.svc/{Document_Library_name}*
In the response I get xml containing details of files uploaded in document library. One of the tag in response of xml (inside src attribute of tag) contains detail of url of file uploaded,
Now when I try to use this url for document display/download in my application/browser, it pops up with the window authentication which I have for Sharepoint site . After I provide correct user/password the document gets downloaded.
Is it somehow possible to make this document url public(I don't want window authentication pop up) ? At the same time I don't want to disable the Windows authentication for Sharepoint site .
Thanks in advance
By public do you mean accessible within your LAN or accessible from the internet given the sharepoint site is bound to an internet facing interface? I would imagine on the LAN it would be best to simply use the guest account for users who you wanted to give 'public' access to.
Bear in mind the only reason you're prompted for login details is probably because you're not using Internet Explorer.

Resources