将geoserver cURL转换为python请求
使用Django with,我想调用由Geoserver配置的rest服务器。在中,有一些卷发可用于与服务器通信。 例如,此卷曲:将geoserver cURL转换为python请求,python,django,curl,python-requests,geoserver,Python,Django,Curl,Python Requests,Geoserver,使用Django with,我想调用由Geoserver配置的rest服务器。在中,有一些卷发可用于与服务器通信。 例如,此卷曲: curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<workspace><name>acme</name></workspace>" http://localhost:8080/geoserver/rest/workspace
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml"
-d "<workspace><name>acme</name></workspace>"
http://localhost:8080/geoserver/rest/workspaces
curl-v-u管理员:geoserver-XPOST-H“内容类型:text/xml”
-d“顶点”
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)
payload={'-d':'acme'}
标题={'content-type':'text/xml'}
r=请求。post(“http://localhost:8080/geoserver/rest/workspaces,auth=('admin','geoserver'),
数据=有效负载,标题=标题)
我明白了:
headers = {'content-type': 'text/xml'}
r1 = requests.post("http://localhost:8080/geoserver/rest/workspaces",
auth=('admin', 'geoserver'),
data='<workspace><name>acme</name></workspace>',
headers=headers)
headers={'content-type':'text/xml'}
r1=请求。post(“http://localhost:8080/geoserver/rest/workspaces",
auth=('admin','geoserver'),
data='acme',
页眉=页眉)