SharePoint GetListItems VBA not working

landolfi

New Member
Joined
May 19, 2014
Messages
5
Hi all,

After having considerable success with SOAP calls to SharePoint, I'm now stumped on GetListItems. This code appears correct to me and the SOAP request header was borrowed from code that is working so my assumption, whether correct or not, is that there is something wrong with the format of the specific GetListItems request because I consistently get a BAD REQUEST HTTP response. I've included all the tags for all elements, but my understanding from the confusing SP WSS 3 documentation is that pretty much everything except listName and an empty queryOption tag is optional. So I'm stumped. Any ideas?

sURL = "https://in2.nokia.com/sites/" & SiteURL & "/_vti_bin/Lists.asmx?op=GetListItems"
sEnv = "<!--?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?-->"
sEnv = sEnv & "<soap:envelope xmlns:xsi=" & Chr(34) & " http:="" www.w3.org="" 2001="" xmlschema-instance"="" &="" chr(34)="" "="" xmlns:xsd=" & Chr(34) & " xmlschema"="" xmlns:soap=" & Chr(34) & " schemas.xmlsoap.org="" soap="" envelope="">"
sEnv = sEnv & "<soap:body>"
sEnv = sEnv & "<getlistitems xmlns=" & Chr(34) & " http:="" schemas.microsoft.com="" sharepoint="" soap="" "="" &="" chr(34)="">"
sEnv = sEnv & "<listname>{600FD7EF-4AE4-4B49-A4BF-49AAB0D7C739}</listname>"
sEnv = sEnv & "<viewname></viewname>"
sEnv = sEnv & "<query></query>"
sEnv = sEnv & "<viewfields></viewfields>"
sEnv = sEnv & "<rowlimit></rowlimit>"
sEnv = sEnv & "<queryoptions></queryoptions>"
sEnv = sEnv & "<webid></webid>"
sEnv = sEnv & "</getlistitems>"
sEnv = sEnv & "</soap:body>"
sEnv = sEnv & "</soap:envelope>"
With xmlhtp
.Open "POST", sURL, False
.setRequestHeader "Host", ""
.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
.setRequestHeader "Content-Length", "255"
.setRequestHeader "soapAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems"
.send sEnv
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
if you step though this what does sEnv look like in Immediate window, can you pick up the compiled values and make that work
 
Upvote 0
That was a good tip, when I was able to see the full SOAP request I could see that I was closing the GetListItems tag before the other tags could be read by putting an extra "/" in. Also, I deleted the empty queryOptions and all the others. Now it works wth just a listName tag and GUID. Thanks very much.
 
Upvote 0
glad to help, I use that for SQL when it falls over :)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top