cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Copy List Item into a Doc Library using UpdateListItems

Hi All,

 

I'm trying to copy a list item into folder in a document library.

I have used the "Lists.asmx" webservice for it and the "UpdateListItems" webmethod.

Below is my XML, I have used a "FileDirRef" to provide the folder under which I need to copy the item.

But the item is been copied outside the folder at the library level.

 

XML

<m:UpdateListItems>

      <m:listName>Archival List</m:listName>

      <m:updates>

        <Batch OnError="Continue" ListVersion="1" ViewName="">

          <Method ID="1" Cmd="New">

            <Field Name="er">Test</Field>

            <Field Name="FileDirRef">[Site URL]/Sites/C0001968/Archival List/18-May-2015</Field>

          </Method>

        </Batch>

      </m:updates>

    </m:UpdateListItems>

 

Output:

 

Can someone please tell where I'm going wrong.

Thanks in Advance

 

Regards,

Shyam

Labels: (1)
Tags (1)
0 Kudos
Reply
5 Replies
Not applicable

Re: Copy List Item into a Doc Library using UpdateListItems

Shyam,

Have you considered using the copy.asmx web service instead? You can find more information regarding this web service here: Copy.CopyIntoItems Method (Copy).

Try using the CopyIntoItems Method instead and see if you have more success.

Cheers,

Andrew Beals

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Copy List Item into a Doc Library using UpdateListItems

Hi Andrew,

I have tried using "Copy.asmx" webservice and the CopyIntoItems method.

XML

<m:CopyIntoItems>

      <mSmiley FrustratedourceUrl>[Site URL]/Sites/C0001968/Lists/PPV%20List/AllItems.aspx</mSmiley FrustratedourceUrl>

      <mSmiley Very HappyestinationUrls>

        <m:string>[Site URL]/Sites/C0001968/Archival%20List/18-May-2015</m:string>

      </mSmiley Very HappyestinationUrls>

      <m:Fields>

        <m:FieldInformation Type="Text" DisplayName="er" Value="Test"></m:FieldInformation>

      </m:Fields>

      <mSmiley Frustratedtream>base64Binary</mSmiley Frustratedtream>

    </m:CopyIntoItems>

But, I'm getting an error,

Response

<CopyIntoItemsResult>0</CopyIntoItemsResult>

      <Results>

        <CopyResult ErrorCode="Unknown" ErrorMessage="A file with the name Archival List/18-May-2015 already exists. It was last modified by i:0#.w|common\ssh6626 on 18 mei 2015 09:13:49 +0200." DestinationUrl="[Site URL]/Sites/C0001968/Archival%20List/18-May-2015" />

      </Results>

    </CopyIntoItemsResponse>

Could you please help me with this.

Thanks in Advance.

Regards,

Shyam

0 Kudos
Accept as Solution Reply
Not applicable

Re: Copy List Item into a Doc Library using UpdateListItems

Shyam,

 

According to your XML it looks like you are providing the wrong URL in two places:

 

<mSmiley FrustratedourceUrl>[Site URL]/Sites/C0001968/Lists/PPV%20List/AllItems.aspx</mSmiley FrustratedourceUrl>

-Change this to reflect the file you are trying to copy. For example /ppv%20list/file.txt

 

<mSmiley Very HappyestinationUrls><m:string>[Site URL]/Sites/C0001968/Archival%20List/18-May-2015</m:string></mSmiley Very HappyestinationUrls>

-With this syntax you are trying to create the item "18-may-2015". Try adding the file name to the end of the URL ie. /C0001968/Archival%20List/18-May-2015/item.txt

 

Ensure that your site URL's include the file name when you're configuring your web service. I have written an example web service call with 'copyintoitems' below that you can use to get a better idea of how to configure your request:

 

<?xml version="1.0" encoding="utf-16"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <soap:Body>

    <CopyIntoItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">

      <SourceUrl>http://test.com/LibraryA/wesdfsdfsdfsdfsd.docx</SourceUrl>

      <DestinationUrls>

        <string>http://test.com/LibraryB/wesdfsdfsdfsdfsd.docx</string>

      </DestinationUrls>

      <Fields>

        <FieldInformation Type="URL" DisplayName="test" InternalName="test" Id="00000000-0000-0000-0000-000000000000" Value="" />

      </Fields>

      <Stream>AA==</Stream>

    </CopyIntoItems>

  </soap:Body>

</soap:Envelope>

 

I configured this call using "web service studio" found here: WebServiceStudio - Home

 

Cheers,

Andrew Beals

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Copy List Item into a Doc Library using UpdateListItems

Hi Andrew,

Thanks for the reply.

I could achieve the required functionality.

Regards,

Shyam

0 Kudos
Accept as Solution Reply
Not applicable

Re: Copy List Item into a Doc Library using UpdateListItems

Shyam,

Thanks for the follow up! Glad to hear it helped in the end!

Cheers,

Andrew Beals

0 Kudos
Accept as Solution Reply