tags:

views:

74

answers:

1

Hello,

I am attempting to pull list Items from a sharepoint server(via python/suds) and am having some difficulty with making queries to GetListItems. If i provide no other parameters to GetListItems other than the list Name, it will return all the items in the default view for that List. I want to query a specific set of items(ID=15) to be returned and a specific set of fields(Date and Description) to be returned for those items. Here is my SOAP packet:

<?xml version="1.0" encoding="UTF-8"?>
<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/"&gt;
<SOAP-ENV:Header/>
<ns0:Body>
  <ns1:GetListItems>
     <ns1:listName>MyCalendar</ns1:listName>
     <query>
        <Where>
           <Eq>
              <FieldRef Name="_ows_ID">15</FieldRef>
           </Eq>
        </Where>
     </query>
     <viewFields>
        <FieldRef Name="Description"/>
        <FieldRef Name="EventDate"/>
     </viewFields>
  </ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>

This appears to conform to the WSDL, however, when making the query i get back a full list of items with all the fields(as if i did not pass any query XML at all).

Any suggestions for a SOAP noob?

Also, here is my python code that generated this XML:

query = Element('query')
where = Element('Where')
eq = Element('Eq')
eq.append(Element('FieldRef').append(Attribute('Name', '_ows_ID')).setText('15'))
where.append(eq)
query.append(where)

viewFields = Element('viewFields')
viewFields.append(Element('FieldRef').append(Attribute('Name','Description')))
viewFields.append(Element('FieldRef').append(Attribute('Name','EventDate')))

results = c_lists.service.GetListItems('MyCalendar', None, query, viewFields, None, None)

Any help would be greatly appreciated!

+1  A: 

I figured this one out. The problem was the CAML query.

1. You need to wrap the CAML 'Query' in a 'query' element.

2. You need to set the proper 'Value Type' Element and attributes.

See me other posting titled 'Sharepoint Filter for List Items(GetListItems)' for more info and code.

Thanks! Nick

nnachefski