I am using Zeep to try and interact with a SOAP client on SellerCloud. When I pass in my argument for one of the API's operations, I get hit with a ValueError -
ValueError: dictionary update sequence element #0 has length 15; 2 is required
Here is the relevant code:
from zeep import Client
import datetime
wsdl_url = "http://tt.ws.sellercloud.com/scservice.asmx?WSDL"
client = Client(wsdl_url)
auth_type = client.get_type("ns0:AuthHeader")
sc_auth = auth_type(UserName=<username>, Password=<password>)
from_date = datetime.date(2018, 7, 3).strftime("%Y-%m-%d %H:%M:%S")
to_date = datetime.date(2018, 7, 11).strftime("%Y-%m-%d %H:%M:%S")
sc_keys = ["DateFrom", "DateTo", "UseSP", "ShippingStatusKind", "IncludeDS"]
sc_values = [from_date, to_date, "GET", "1", "TRUE"]
filters_type = client.get_type("ns0:SerializableDictionaryOfStringString")
filters = filters_type(sc_keys, sc_values)
print filters
print 'length of filters - ', len(filters)
with client.settings(extra_http_headers=sc_auth, force_https=False):
order_ids = client.service.Orders_Get(filters)
And the stack trace error -
Traceback (most recent call last):
File "seller-cloud.py", line 24, in <module>
order_ids = client.service.Orders_Get(filters)
File "/home/user/Envs/seller-cloud/local/lib/python2.7/site-packages/zeep/proxy.py", line 42, in __call__
self._op_name, args, kwargs)
File "/home/user/Envs/seller-cloud/local/lib/python2.7/site-packages/zeep/wsdl/bindings/soap.py", line 121, in send
options=options)
File "/home/user/Envs/seller-cloud/local/lib/python2.7/site-packages/zeep/wsdl/bindings/soap.py", line 99, in _create
http_headers.update(client.settings.extra_http_headers)
ValueError: dictionary update sequence element #0 has length 15; 2 is required
And the output of my print statements prior to where the error is happening -
{
'Keys': [
'DateFrom',
'DateTo',
'UseSP',
'ShippingStatusKind',
'IncludeDS'
],
'Values': [
'2018-07-03 00:00:00',
'2018-07-11 00:00:00',
'GET',
'1',
'TRUE'
]
}
length of filters - 2
I've been banging my head on this for a while but can't seem to find where this whole length of 15 deal is happening. Even if I pass in an empty array like : filters = filters_type([])
, I still get a length of 15 error.
Based on the traceback it is failing when updating HTTP headers here:
http_headers.update(client.settings.extra_http_headers)
I would investigate if extra_http_headers=sc_auth
sets the right headers. It looks like you need to pass there plain HTTP headers (a dict) and you are giving it some SOAP structure.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments