[Geoserver-users] problem uploading a zip file with rest and python

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)