tags:

views:

449

answers:

3

How can I insert a list item in a folder within a list, using list web services (UpdateListItem).

The breadcrumb of the folder would be something like this. [My site] > [My list] > [My sub folder]

I have tried with a CAML like this:

 <Batch PreCalc="TRUE"
 OnError="Continue"
 RootFolder="/Lists/MyList/MySubFolder">
 <Method ID="1" Cmd="New">
       <Field Name="Title">Gent</Field>
       <Field Name="PostalCode">9000</Field>
       <Field Name="TelephoneZone">09</Field>   
</Method> </Batch>

But unsuccessfully.

I am getting as response: Invalid URL value.
**If I remove the RootFolder attribute it works fine, but the item gets inserted outside the folder.

A: 

Have you tried inserting the item into the list, then making a second call to update the metadata and stick it in the right folder?

Goyuix
Inserting the item in the list no problem. How to update it later so it goes into a given folder I don't know how to do.
AlejandroR
A: 

If you're able to deploy code to the server i'd roll my own web service that does the job. That way you get access to the entire object model.

Jason Watts
+3  A: 

Problem solved.

The "RootFolderAttribute" should not be RootFolder="/Lists/MyList/MySubFolder" but "/sites/MySite/Lists/MyList/MySubfolder"

Could solved it thanks to a tool named u2u CAML Query Builder.

AlejandroR
Yes, MySites is on a seperate site collection, so the /sites/ wildcard inclusion is required. CAML Query Builder is a great tool btw and has saved my hide many a time!
Jason Watts