Python 列表项的Sharepoint筛选器(GetListItems)
我正试图通过Web服务从sharepoint获取一组列表项。我想查询一小部分要返回的项目。我的SOAP数据包似乎顺序正确,但是,服务似乎仍然忽略了我的设置过滤器(查询)。你知道为什么这种情况还会发生吗Python 列表项的Sharepoint筛选器(GetListItems),python,sharepoint,soap,Python,Sharepoint,Soap,我正试图通过Web服务从sharepoint获取一组列表项。我想查询一小部分要返回的项目。我的SOAP数据包似乎顺序正确,但是,服务似乎仍然忽略了我的设置过滤器(查询)。你知道为什么这种情况还会发生吗 <SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http
<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:GetListItems>
<ns1:listName>MyCalendar</ns1:listName>
<query>
<Query>
<Where>
<Eq>
<FieldRef Name="EventDate"/>
<Value Type="DateTime">[Now+2Minute(s)]</Value>
</Eq>
</Where>
</Query>
</query>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
编辑:
下面是正确的soap数据包和肥皂水代码,它们最终对我有用。我对过滤器有一些奇怪的要求,但我会继续按原样发布,以便其他人可以从中学习
<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:GetListItems>
<ns1:listName>Economic Event Calendar</ns1:listName>
<ns1:query>
<Query>
<Where>
<And>
<Geq>
<FieldRef Name="EventDate"/>
<Value IncludeTimeValue="TRUE" Type="DateTime">2010-08-12T07:38:00</Value>
</Geq>
<Lt>
<FieldRef Name="EventDate"/>
<Value IncludeTimeValue="TRUE" Type="DateTime">2010-08-12T07:39:00</Value>
</Lt>
</And>
</Where>
</Query>
</ns1:query>
<ns1:rowLimit>5</ns1:rowLimit>
<viewFields>
<FieldRef Name="Description"/>
<FieldRef Name="EventDate"/>
</viewFields>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
尝试在
值
元素上使用IncludeTimeValue
属性:
<Value Type="DateTime" IncludeTimeValue="TRUE">[Now+2Minute(s)]</Value>
[现在+2分钟]
根据:
IncludeTimeValue:可选布尔值。指定基于时间和日期生成日期时间查询。如果未设置此属性,则将忽略查询中涉及日期和时间的时间部分
我在CAML查询中没有使用太多的DateTime筛选器,但您的SOAP数据包的其他所有内容看起来都是正确的。CBono,没错,先生!我在贴了几小时后就发现了这个。U2U的CAML生成器在这个问题上帮了我很大的忙。谢谢你的回复!是的,CAML Builder是SP开发人员必备的工具。
#craft our XML
Query = Element('Query')
where = Element('Where')
And = Element('And')
geq = Element('Geq')
geq.append(Element('FieldRef').append(Attribute('Name', 'EventDate')))
vt = Element('Value').append(Attribute('IncludeTimeValue', 'TRUE'))
vt.append(Attribute('Type', 'DateTime')).setText(convert_dt('now +' + str(alertBefore) + ' minutes', '%Y-%m-%dT%H:%M:00' ))
lt = Element('Lt')
lt.append(Element('FieldRef').append(Attribute('Name', 'EventDate')))
vt2 = Element('Value').append(Attribute('IncludeTimeValue', 'TRUE'))
vt2.append(Attribute('Type', 'DateTime')).setText(convert_dt('now +' + str((alertBefore + 1)) + ' minutes', '%Y-%m-%dT%H:%M:00' ))
#viewFields fragment, only show the Description and EventDate for returned rows
viewFields = Element('viewFields')
viewFields.append(Element('FieldRef').append(Attribute('Name','Description')))
viewFields.append(Element('FieldRef').append(Attribute('Name','EventDate')))
#pack all the XML fragments
geq.append(vt)
lt.append(vt2)
where.append(And)
And.append(geq)
And.append(lt)
Query.append(where)
query = Element('ns1:query')
query.append(Query)
#issue the query
results = c_lists.service.GetListItems(SPCal, None, query, None, 5, viewFields, None)
<Value Type="DateTime" IncludeTimeValue="TRUE">[Now+2Minute(s)]</Value>