0
使用Django和requests,我想調用由Geoserver配置的其餘服務器。在Geoserver docs中,有一些cURL可用於與服務器進行通信。 例如,這個捲曲:將geoserver cURL轉換爲python請求
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml"
-d "<workspace><name>acme</name></workspace>"
http://localhost:8080/geoserver/rest/workspaces
創建一個新的工作區。 如何將此cURL轉換爲python請求?此外,我使用下面的代碼,但它不成功。
payload = {'-d':'<workspace><name>acme</name></workspace>'}
headers = {'content-type': 'text/xml'}
r = requests.post("http://localhost:8080/geoserver/rest/workspaces", auth=('admin', 'geoserver'),
data=payload,headers=headers)