hi all,

I try to upload an zip archive containing shapefiles to geoserver via the rest 
interface

with curl in the shell  it works fine:

/usr/bin/curl -v -u admin:geoserver -XPUT -H 'Content-type: application/zip' -T 
data/diva/DEU_rrd.zip 
http://192.168.56.101:8080/geoserver/rest/workspaces/diva/datastores/newDivaSHP/file.shp


If I try the same task within python

import requests
myUrl = 
'http://192.168.56.101:8080/geoserver/rest/workspaces/diva/datastores/newDivaSHP/file.shp'
headers = {"Content-type: application/zip"}
zipFile = open('data/diva/DEU_rrd.zip','rb')
payload = zipFile.read()
resp = 
requests.put(myUrl,auth=('admin','geoserver'),headers=headers,data=payload)
print(resp.status_code)
print(resp.content)


I get the error message pasted below

Does anybody have a idea what I am doing wrong with the python code.
Best regards and thanks
Christian


In [24]: resp = 
requests.put(myUrl,auth=('admin','geoserver'),headers=headers,data=payload)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/Users/chrischi/<ipython-input-24-ab842e61d9c2> in <module>()
----> 1 resp = 
requests.put(myUrl,auth=('admin','geoserver'),headers=headers,data=payload)

~/ENV01/lib/python2.7/site-packages/requests/api.pyc in put(url, data, **kwargs)
     97     """
     98
---> 99     return request('put', url, data=data, **kwargs)
    100
    101

~/ENV01/lib/python2.7/site-packages/requests/api.pyc in request(method, url, 
**kwargs)
     42
     43     session = sessions.Session()
---> 44     return session.request(method=method, url=url, **kwargs)
     45
     46

~/ENV01/lib/python2.7/site-packages/requests/sessions.pyc in request(self, 
method, url, params, data, headers, cookies, files, auth, timeout, 
allow_redirects, proxies, hooks, stream, verify, cert)
    320         # Merge all the kwargs.

    321         params = merge_kwargs(params, self.params)
--> 322         headers = merge_kwargs(headers, self.headers)
    323         auth = merge_kwargs(auth, self.auth)
    324         proxies = merge_kwargs(proxies, self.proxies)

~/ENV01/lib/python2.7/site-packages/requests/sessions.pyc in 
merge_kwargs(local_kwarg, default_kwarg)
     54
     55     default_kwarg = from_key_val_list(default_kwarg)
---> 56     local_kwarg = from_key_val_list(local_kwarg)
     57
     58     # Update new values in a case-insensitive way


~/ENV01/lib/python2.7/site-packages/requests/utils.pyc in 
from_key_val_list(value)
    113         raise ValueError('cannot encode objects that are not 2-tuples')
    114
--> 115     return OrderedDict(value)
    116
    117

~/ENV01/lib/python2.7/site-packages/requests/packages/urllib3/packages/ordered_dict.pyc
 in __init__(self, *args, **kwds)
     41             root[:] = [root, root, None]
     42             self.__map = {}
---> 43         self.__update(*args, **kwds)
     44
     45     def __setitem__(self, key, value, dict_setitem=dict.__setitem__):

~/ENV01/lib/python2.7/site-packages/requests/packages/urllib3/packages/ordered_dict.pyc
 in update(*args, **kwds)
    167                 self[key] = other[key]
    168         else:
--> 169             for key, value in other:
    170                 self[key] = value
    171         for key, value in kwds.items():

ValueError: too many values to unpack




------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to