Posts

Showing posts with the label Document ID

C# Http Method How to Upload Document into SharePoint Online Document Library

Image
In this article we will see how to upload file into SharePoint Online Document Library using REST API and HTTP method. Also you will drr how to get the document ID of the same upload document. Here is the code:             string filePath = @"C:\MyFile.pdf";             string siteUrl = "https://domainname.sharepoint.com/sites/contoso5/"             byte[] bytefile = System.IO.File.ReadAllBytes(filePath);             HttpWebRequest endpointReq = (HttpWebRequest)HttpWebRequest.Create(siteUrl + "/_api/web/GetFolderByServerRelativeUrl('DocLib/MyFolder')/Files/add(url='Myfile.pdf',overwrite=true)?$expand=ListItemAllFields");             endpointReq.Method = "POST";             endpointReq.Headers.Add("binaryStringRequestBody", "true");             endpointReq.Headers.Add("Authorizatio...

C# CSOM How to Upload Document into SharePoint Online Document Library

Image
In this article we will see how to upload document into SharePoint Online Document Library using SharePoint Client Object Model CSOM. Also I have given piece of code to get document ID of the  uploaded document. Here is the code:             string siteUrl = "https://domainname.sharepoint.com/sites/contoso5/";             string docUrl = "https://domainname.sharepoint.com/sites/contoso5/DocLib/MyFolder/NewPDF.pdf";             string pathToFile = @"C:\NewPDF.pdf";             var clientContext = GetClientContext(siteUrl);             Web web = clientContext.Web;             clientContext.Load(web, a => a.ServerRelativeUrl);             clientContext.ExecuteQuery();             List documentsList = clientContext.Web.Lists.GetByTitle("DocLib"); ...