I am trying to upload document files to a document library in SharePoint using the CopyIntoItems method of the SharePoint Copy web service.
The code below executes and returns 0 (success). In addition, the CopyResult [] array returns 1 value with the result "Success". However, I cannot find the document anywhere in the library.
I have two questions:
- Can someone see something wrong with my code or suggest changes?
- Can anyone suggest me debug this on the server side. I do not have much experience with SharePoint. If I can track what happens through logging or some other server-side method, this can help me figure out what is going on.
Code example:
string[] destinationUrls = { Uri.EscapeDataString("https://someaddress.com/Reports/Temp") }; SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Name", InternalName = "Name", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Name" }; SPCopyWebService.FieldInformation i2 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" }; SPCopyWebService.FieldInformation[] info = { i1, i2 }; SPCopyWebService.CopyResult[] result; byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt"); uint ret = SPCopyNew.CopyIntoItems("", destinationUrls, info, data, out result);
Change what happened:
I got my code by adding " http: // null " to the SourceUrl field. The nat answer below is likely to work for this reason. Here is the line I changed to make it work.
// Change uint ret = SPCopyNew.CopyIntoItems("http://null", destinationUrls, info, data, out result);
source share