LuTheZy
LuTheZy

Reputation: 61

Uploading Files to SharePoint 2010 via Windows Service using CSOM 404 not found error

Hi all I am currently working on application that needs to create document sets on SharePoint 2010 and upload files into these document sets. The application will be deployed as a Windows Service. When I debug the application in Visual Studio it works perfectly but when I deploy it as a Windows Service I get the following error:

System.Net.WebException: The remote server returned an error: (404) Not Found.
 at System.Net.HttpWebRequest.GetResponse()
 at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at PensionerPayroll.BusinessLayer.SharePointHelper.CreateDocumentSet(ClientContext context, List`1 fieldNames, String[] fieldValues, String documentLibraryName)
at PensionerPayroll.BusinessLayer.Controllers.FolderSweeper.CreateECMEntry(String[] 
 fieldValues, String[] fileNames, String metadataFileName)
 at PensionerPayroll.BusinessLayer.Controllers.FolderSweeper.SweepFiles()

I have tried to deploy the Windows Service using both my own credentials and service account credentials, both of which have the highest permissions to the SharePoint Site. I have installed the Microsoft SharePoint 2010 SDK on the server that will host the Service. The application is built on the .NET framework 4.6. Could the problem be the .NET framework version?

Upvotes: 0

Views: 701

Answers (1)

Prany
Prany

Reputation: 2133

The main cause for this type of error is that you don't have the IIS header configured properly. The (404) Not Found will appear because you are hitting a different IIS web site and not the one you want redirect to. You can go into IIS Manager and click on Sites there should be a column called bindings and a column called ID. Make sure you stop the default site.

IIS will check in the order of ID for the first website if it matches.eg. ID 1: Bindings: *:80

Upvotes: 1

Related Questions