开发者

Sharepoint/SOAP - GetListItems ignoring query

开发者 https://www.devze.com 2023-02-11 06:55 出处:网络
Trying to talk from Python to Sharepoint through SOAP. One of the lists I am trying to query contains \'ID\' as primary key field.

Trying to talk from Python to Sharepoint through SOAP.

One of the lists I am trying to query contains 'ID' as primary key field.

(Field){
   _RowOrdinal = "0"
   _FromBaseType = "TRUE"
   _DisplayName = "ID"
   _Name = "ID"
   _SourceID = "http://schemas.microsoft.com/sharepoint/v3"
   _ColName = "tp_ID"
   _StaticName = "ID"
   _PrimaryKey = "TRUE"
   _ReadOnly = "TRUE"
   _Type = "Counter"
   _ID = "{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}"
},

We send the follow开发者_运维问答ing request to query the list item with ID=77

<?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/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:GetListItems>
         <ns1:listName>60e3f442-6faa-4b49-814d-2ce2ec88b8d5</ns1:listName>
         <query><Query><Where>
            <Eq>
               <FieldRef Name="ID"/>
               <Value Type="Counter">77</Value>
            </Eq>
         </Where></Query></query>
       </ns1:GetListItems>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

However Sharepoint returns all items from the list completely ignoring the query.

Any idea?


The actual turned out to be that it is necessary to use

<ns1:query> 

here (for whatever reason).


Try Type="Number" instead of Counter. I've just been through a bunch of code I wrote a while back to get list items based on the ID and I have used Number, and it works.

You may also need to include the empty elements for views and stuff too. Below is a fragment of my generated request:

 <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <listName>Workgroups</listName>
  <viewName />
  <query><Query>
   <Where><Eq><FieldRef Name="ID"/><Value Type="Number">101</Value></Eq></Where>
  </Query></query>
  <viewFields><ViewFields><FieldRef Name="Title"/><FieldRef Name="Leader" /><FieldRef Name="Members" /><FieldRef Name="hiddenmembers" /></ViewFields></viewFields>
  <rowLimit />
  <queryOptions><QueryOptions /></queryOptions>
 </GetListItems>
0

精彩评论

暂无评论...
验证码 换一张
取 消