Python - ValueError: dictionary update sequence element #0 has length 15; 2 is required

demluckycharms

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.

Santiago Bruno

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.

edited at
0

Comments

0 comments
Login to comment

Related

dictionary update sequence element #0 has length 15; 2 is required

Tuple (key, value) to dictionary ValueError: dictionary update sequence element #0 has length 6; 2 is required

ValueError: dictionary update sequence element #0 has length 25; 2 is required When Unpacking a tuple with a dictionary

default_attrs.update(attrs) ValueError: dictionary update sequence element #0 has length 1; 2 is required

ValueError: dictionary update sequence element #0 has length 1; 2 is required

ValueError: dictionary update sequence element #0 has length 14; 2 is required

dictionary update sequence element #0 has length 3; 2 is required

dictionary update sequence element #0 has length 4; 2 is required

Python ValueError: dictionary update sequence element #4 has length 3; 2 is required

Convert To Dictionary in Robot Framework gives the error "ValueError: dictionary update sequence element #0 has length 1; 2 is required"

ValueError: dictionary update sequence element #0 has length 3; 2 is required when attempting to coerce generator function into dictionary

dictionary update sequence element #0 has length 1; 2 is required Error | Python

Getting an error: "ValueError: dictionary update sequence element #0 has length 1; 2 is required" when used map function

Django dictionary update sequence element #0 has length 0; 2 is required

dictionary update sequence element #0 has length 1; 2 is required when loading page

Django - Dictionary update sequence element #0 has length 1; 2 is required

Dictionary update sequence element #0 has length 1; 2 is required in Django

Value error dictionary update sequence element #0 has length 1; 2 is required

Brownie project, failed to compile Solidity code: dictionary update sequence element #0 has length 1; 2 is required

"ValueError: Asked to retrieve element 0, but the Sequence has length 0" in Convolutional Neural Network

Dictionary error: cannot convert dictionary update sequence element #0 to a sequence

TypeError: cannot convert dictionary update sequence element #0 to a sequence

plotly: TypeError: cannot convert dictionary update sequence element #0 to a sequence

ValueError: expected sequence of length 0 at dim 2 (got 1)

Tuple to Dict :: TypeError: cannot convert dictionary update sequence element #0 to a sequence

Identical **kwargs, but one raising "cannot convert dictionary update sequence element #0 to a sequence"

Error in Image generator : Asked to retrieve element 0, but the Sequence has length 0

Error splitting string python, has length 1, 2 is required

Python numpy ValueError: setting an array element with a sequence