I´m trying the UpdateListItems web service but I always get following error in the response file: Data at the root level is invalid. Line 1, position 1. GetList, GetListItems and DeleteList works.

Here is the full Response:

<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><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Data at the root level is invalid. Line 1, position 1.</errorstring></detail></soap:Fault></soap:Body></soap:Envelope>    

This is the VBA Code I wrote:

Sub AddItems()
Dim sURL As String
Dim sEnv As String
Dim xmlhtp As New MSXML2.XMLHTTP
Dim xmlDoc As New DOMDocument
Dim BatchXml As String
Dim Batch As String
Dim FieldNameVar As String
Dim ValueVar As String

strBatchXml = "<Batch OnError='Continue'><Method ID='1' Cmd='Delete'><Field Name='ID'>1</Field></Method></Batch>"

sURL = "https://sharepoint/adm/spiwi/ei/_vti_bin/lists.asmx"
sEnv = "<?xml version=""1.0"" encoding=""UTF-8""?>"
sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
sEnv = sEnv & "  <soap:Body>"
sEnv = sEnv & "    <UpdateListItems xmlns=""http://schemas.microsoft.com/sharepoint/soap/"">"
sEnv = sEnv & "      <listName>TestListe</listName>"
sEnv = sEnv & "      <updates>strBatchXml</updates>"
sEnv = sEnv & "    </UpdateListItems>"
sEnv = sEnv & "  </soap:Body>"
sEnv = sEnv & "</soap:Envelope>"

With xmlhtp
    .Open "POST", sURL, False
    .setRequestHeader "Host", "occ.t-mobile.at"
    .setRequestHeader "Content-Type", "text/xml; charset=UTF-8"
    .setRequestHeader "Content-Length", "length"
    .setRequestHeader "soapAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"
    .send sEnv
    xmlDoc.LoadXML .responseText
    xmlDoc.Save "D:\users\Tom\Downloads\UpdateItems.xml"
End With
End Sub

I want to delete all list items but not the list. Can someone of you coding pros maybe tell me, what I've done wrong with this code?

1 Answer 1


Ok, i´ve got it. I changed

sEnv = sEnv & "      <updates>strBatchXml</updates>" 


sEnv = sEnv & "      <updates>" + strBatchXml + "</updates>      

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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