BizTalk : Uploading files to SharePoint using Client Object Model

I have used different methods to upload documents to SharePoint from BizTalk which includes using BizTalk SharePoint Adapter, Sharepoint Services and also by using SharePoint 2010 Client Object Model.

 In this article i will use SharePoint Object Model to upload documents to SharePoint using BizTalk 2010.

I have a requirement where documents need to be uploaded to SharePoint 2010 from BizTalk. I have created a C# project which i will be using to reference SharePoint 2010 client objet model dlls. This project is referenced in BizTalk Orchestration project.

As a first step i will add SparePoint 2010 Client Object Model Dll’s. I have nuget installed so i will use nuget to download the package which will add the the dll references

Nuget Packages



If you do not have nuget, download the dll’s separately and reference to your project.

Reference the library in your Class as follows

Add namespaces

Below is the code to upload documents to SharePoint 2010

using (ClientContext clientContext = new ClientContext(siteURL))
                    // Set Credentials
                    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(SharePointUsername, SharePointPassword, SharePointDomain);
                    clientContext.Credentials = credentials;
                    clientContext.RequestTimeout = 100000;

                    //Load web
                    Web web = clientContext.Web;

                    //Get Document List
                    List documentsList = web.Lists.GetByTitle(sharePointLibrary);

                    //Load SharePoint library Lists

                    var fileCreationInformation = new FileCreationInformation();

                    fileCreationInformation.Content = System.IO.File.ReadAllBytes(receiveLocation);

                    fileCreationInformation.Url = sendLocation;

                    Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(fileCreationInformation);


In the expression Shape I will call the method to upload file using Client Object Model

SP Upload Expression

The file will be uploaded and you will be able to see the documents in SharePoint.

Tagged with: , , , , , , , , , , , ,
Posted in BizTalk, Integration, SharePoint, Uncategorized

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: