I need some help with Server to Server upload. (not from the browser)

Has anyone uploaded files to sharepoint 2013, using REST, or other methods from a server (java/coldfusion/other).

I am getting a digest value ... is this available only from> subdomain.sharepoint.com/sites/site1[/_api/Web/Context]

I have tried converting files to binary and uploading as body content to :

subdomain.sharepoint.com/sites/site1/subsite2/subsite3/document library/folder/{here} [ getting: [is not valid]]

I have seen documentation that says this is the only place things can be uploaded subdomain.sharepoint.com/sites/site1/document/shared documents/{here} [is not valid]

Some of my peers tried using the rest request to copy from (subdomain.com) to (subdomain.sharepoint.com) [Connection failure] This failed; firewalls.

Is the documentation flawed? Wrong?


This may not be what you're trying to do, but I wrote a c# console application that will upload documents from my local system to SharePoint while setting the appropriate meta data for our organization (via the Microsoft.SharePoint.Client.Online.CSOM nuget package). Unfortunately, I can't share the code in full, but I can share enough to give you a really good idea of how to do this. It was a full 2 weeks of plucking along and along little by little. I had to piece this together article by article as I could find an example this succinct and I was also very new to SharePoint and learning CSOM and SharePoint at the same time.

Also, I can't find a direct link for it, but there is a SharePoint 2013 Rest Syntax poster that has really helped me drill into sharepoint bit by bit. Try googling SharePoint 2013 Rest Syntax poster or SharePoint2013RESTSyntaxPosters.pdf and see if you can find it. It looks over whelming but it's just saying how to build URL's for REST requests. By looking at this poster and your Site Settings --> Site Libraries and Lists, you can nearly deduce all you need.

1) Get your file data as a byte array 2)

            using (ClientContext clientContext = new ClientContext(contextUrl))

                //Get Document List
                List documentsList = clientContext.Web.Lists.GetByTitle(<document list name>);

                //Used to get & set meta data for file
                var libFields = documentsList.Fields;

                //Takes a crap ton of time...I suggest inspecting what fields are in libFields and only loading those
                //but I leave that for you to code
                foreach (var f in libFields)

                var fileCreationInformation = new FileCreationInformation();                
                fileCreationInformation.Content =  <file content byte array variable here > ;

                //Allow owerwrite of document
                fileCreationInformation.Overwrite = true;          

                //Upload URL
                //Url will be something like: http://server/sites/siteName/<Library>/someFileToUpload.pdf 
                //or http://<server>:<port>/<Library>/someFileToUpload.pdf                        
                fileCreationInformation.Url = < put file url here >;
                Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(

                //Set document meta data here. The values used can be deduced from inspecting libFields data.
                uploadFile.ListItemAllFields["Division"] = Department; 
                uploadFile.ListItemAllFields["Functionality"] = DocumentType; 
                uploadFile.ListItemAllFields["Category"] = Category; 
                uploadFile.ListItemAllFields["Title"] = Title;


  • Thanks but I am trying to move from the server, generally not the console. Its not to say its impossible, perhaps an assembly could be referenced. The URL is similar... I keep getting 'is not valid' with no additional information. Is there a specific permissions object that needs to be set? – user3005033 Jul 12 '16 at 20:07
  • I may be missing something...Can you describe your scenario more about why you're moving documents from server A to server B? Is this something you have to do often or something your users will have to do or is it more the initial document load? – jason Jul 12 '16 at 20:55
  • Also, your endpoint in your question: subdomain.sharepoint.com/sites/site1/subsite2/subsite3/document library/folder/{here} [ getting: [is not valid]] does not reference a "/_api/web". That may be your issue in that your not actually calling the api in that second URL. – jason Jul 12 '16 at 20:56
  • Thank you for replying. We are using Sharepoint as a repository for live files while they are in process. The original documents are created in our Coldfusion (java) server and stored on a local file server/(store if you prefer). We are using Sharepoint for edits, change control and history, the users never see the sharepoint interface, don't have to worry about uploads and downloads, they just get to say 'open this document' and when they close word, it gets saved back to sharepoint for them. We had it working for SOAP, we are moving to REST. I am aware of the /_api/web/ virt'folders. – user3005033 Jul 13 '16 at 17:12
  • Jason. The structure shown represents sites for different applications. I have tried a number of URLs, every one fails with 'is not valid'. I have code that works to attach .xlsm to list/list items with a binary stream, however I dont want it on a list, I want it in a folder as represented above. ex can you (or anyone) use the structure above and provide the correct REST API url for an upload. (without using C#, JQuery or a browser, as the files are on the (coldfusion/java) server; not on the users machine. (initially) Thanks. I know the two comments are a bit long winded. – user3005033 Jul 13 '16 at 17:16

Well, it looks like I was doing a few things wrong.

The ColdFusion language I use passes arguments as a structure, the order does not matter. This appears to not be the case for Sharepoint. ex: files/add(overwrite=true,url='#arguments.filename#') is not the same as files/add( url='#arguments.filename#'; overwrite=true; )

I also had [;] semicolons where I needed [,] commas.

All extraneous spaces need to be removed, other spaces need [%20] encoding. Dashes and underlines if encoded show up encoded, wrong. just replace spaces.

I hope this helps someone else.

See Also: Troubling uploading file from (coldfusion) server into sharepoint with Rest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.