I'm having a really tough time debugging a SharePoint SOAP call to create a list item. The SOAP body I'm sending is:

<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:UpdateListItems>
         <ns1:listName>{35BC2CB3-D2FB-4D47-B711-7502819D6E2B}</ns1:listName>
         <ns1:updates>
            <Batch OnError="Continue" ListVersion="1">
               <Method ID="1" Cmd="New">
                  <Field Name="ID">New</Field>
                  <Field Name="Title">Test Summary</Field>
               </Method>
            </Batch>
         </ns1:updates>
      </ns1:UpdateListItems>
   </ns0:Body>
</SOAP-ENV:Envelope>

No matter what I do, I always get back a SoapServerException with, "Value does not fall within the expected range," as the detail. This is on a SharePoint site that I have full access to. It's a newly created list with Title as the only required attribute. How do I figure out what the issue is?

FWIW, I have no problem with other methods like GetList and GetListItems. I'm just having no luck using UpdateListItems to add a new list item.

share|improve this question
How are you generating this SOAP envelope? The only thing I wonder about is that you've explicitly declared your namespace (ns1) for UpdateListItems, listName and updates. If you're doing this, wouldn't you need to declare it on the child nodes of updates as well? – CBono May 4 '11 at 21:20
I'm using the suds module in Python to generate the SOAP envelope and do all the grunt work. I did try specifying the namespace on the child nodes of updates as well, with the same result. – King Chung Huang May 5 '11 at 15:03
And you're accessing the List web service under the same site to which your list belongs? For instance, you shouldn't access the service from the root http://<your_site>/_vti_bin/lists.asmx if your list actually lives in a subsite. – CBono May 5 '11 at 15:17
Yes, it's not in a subsite. And, I'm able to call GetList and GetListItems successfully. – King Chung Huang May 5 '11 at 15:33
feedback

2 Answers

I had this issue myself.

This is the code I used and it seems to work:

batch = Element('Batch').append(Attribute('OnError', 'Return'))
batch.append(Attribute('ListVersion', '1'))

method = Element('Method').append(Attribute('ID', '1'))
method.append(Attribute('Cmd', 'Update'))

method.append(Element('Field').append(Attribute('Name', 'ID')).setText(1))
method.append(Element('Field').append(Attribute('Name', 'Title')).setText('Just Changed It23223'))

batch.append(method)

updates = Element('ns1:updates')
updates.append(batch)

client.service.UpdateListItems('Test', updates)
share|improve this answer
feedback

Please ensure your list ID is correct and fields are using internal names only for the list you are adding item.

Try putting your method inside try catch block. Put below section above catch block to have further details for the exception.

catch (soapserver.soapserverexception ex)
{    
     console.writeline(ex.detail.innertext);
}
share|improve this answer
Based on the Lists.UpdateListItems Method documentation, I've been putting New as the ID for new list items. I've also tried omitting the ID field altogether, with no effect. – King Chung Huang May 5 '11 at 15:06
The detail innertext is what I quoted in my question: “Value does not fall within the expected range.” My frustration has been that I get the same message no matter what I do. There doesn't seem to be a way (that I know of) to get any more details about which field value SharePoint thinks is not in range, or what the range it expects is. – King Chung Huang May 5 '11 at 15:07
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.