首页 > 解决方案 > 无法在 Zeep 中过滤数据

问题描述

我正在使用 Python(Zeep) 从 salesforce 营销云 SOAP API 中提取数据。我能够连接并从中提取数据,但是我无法对其应用过滤器。谁能告诉我我在这里做错了什么?这是我要执行的代码:

from zeep import wsdl         
from zeep.wsse.username import UsernameToken       
from zeep import Client      
client =Client("https://xxxx.soap.marketingcloudapis.com/etframework.wsdl",wsse=UsernameToken('username', 'password'))
requestDictionary = {
    "ObjectType": 'DataExtensionObject[xxx_WEB_FORM_DE]',
    "Properties": ['FirstName','LastName','LastModifiedDate'],
    "Filter": {'Property' : 'LastModifiedDate','SimpleOperator' : 'greaterThan','Value': '9/13/2020 6:37:00 PM'} 
}
response = client.service.Retrieve(RetrieveRequest=requestDictionary)
print(response)

-------------------------------------------------
Output:
**TypeError: {http://exacttarget.com/wsdl/partnerAPI}FilterPart() got an unexpected keyword argument 'Value'. Signature:**

xml 看起来像这样:

<sequence>
...
<element name="ObjectType" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<element name="Properties" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<element name="Filter" type="tns:FilterPart" minOccurs="0" maxOccurs="1"/>
...
</sequence>
</complexType>

<complexType name="FilterPart"/>
<complexType name="SimpleFilterPart">
<complexContent>
<extension base="tns:FilterPart">
<sequence>
<element name="Property" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<element name="SimpleOperator" type="tns:SimpleOperators" minOccurs="1" maxOccurs="1"/>
<element name="Value" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<element name="DateValue" type="xsd:dateTime" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="TagFilterPart">

简单运算符:

<simpleType name="SimpleOperators">
<restriction base="xsd:string">
...
<enumeration value="notEquals"/>
<enumeration value="greaterThan"/>
<enumeration value="lessThan"/>
...
</restriction>
</simpleType>

标签: pythonsoapfiltersalesforcezeep

解决方案


推荐阅读