How do you use the CopyIntoItems method of the SharePoint Copy web service?

前端 未结 3 1206
暗喜
暗喜 2021-01-06 11:25

I am attempting to load document files into a document library in SharePoint using the CopyIntoItems method of the SharePoint Copy web service.

The code below execut

相关标签:
3条回答
  • 2021-01-06 11:47

    I didn't understand very well what you're tying to do, but if you're trying to upload a file from a local directory into a sharepoint library, i would suggest you create a webclient and use uploadata:

    Example (VB.NET):

    dim webclient as Webclient 
    webClient.UploadData("http://srvasddress/library/filenameexample.doc", "PUT", filebytes)
    

    Then you just have to check in the file using the lists web service, something like:

    listService.CheckInFile("http://srvasddress/library/filenameexample.doc", "description", "1")
    

    Hope it was of some help.

    EDIT: Don't forget to set credentials for the web client, etc.

    EDIT 2: Update metada fields using this:

    listService.UpdateListItems("Name of the Library, batchquery)
    

    You can find info on building batch query's in here: link

    0 讨论(0)
  • 2021-01-06 11:52

    The sourceurl is used in Sharepoint. It is a link back to the "Source Document." When in your document library, hover over the item, to the right appears a down pointing triangle. Clicking on it, brings up a menu. Click on the "View Properties" Option. On this page you will see the following "This item is a copy of http://null ( Go To Source Item | Unlink )"

    Because we are using the Copy function Sharepoint is keeping track of the "Source item" as part of the Document Management feature.

    0 讨论(0)
  • 2021-01-06 11:55

    I think the issue may be in trying to set the "Name" property using the webservice. I have had some fail doing that. Given the "Name" is the name of the document, you may have some success with

        string targetDocName = "Test1Name.txt";
        string destinationUrl = Uri.EscapeDataString("https://someaddress.com/Reports/Temp/" + targetDocName);
        string[] destinationUrls = { destinationUrl };
    
        SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
        SPCopyWebService.FieldInformation[] info = { i1};
        SPCopyWebService.CopyResult[] result;
        byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
        uint ret = SPCopyNew.CopyIntoItems(destinationUrl, destinationUrls, info, data, out result);
    

    Note: I have used the "target" as the "source" property. Don't quite know why, but it does the trick.

    0 讨论(0)
提交回复
热议问题