import requests
import json
host = '192.168.221.186'
def getToken(session, user, password):
url = f"http://{host}:8090/iserver/services/security/tokens.rjson"
data = {
"userName": user,
"password": password,
"clientType": "NONE",
"expiration": 10
}
headers = {"Content-Type": "application/json"}
response = session.post(url, data=json.dumps(data), headers=headers)
if response.status_code == 200:
token = response.text
# 登录成功后的操作
print("登录成功")
# 可以在这里添加其他操作
else:
print("登录失败")
# 可以在这里处理登录失败的情况
return token
def getWorkSpace(session, token, host):
url1 = 'http://' + host + ':8090/iserver/manager/providers.rjson?token=' + token
data1 = {"config":{"configFile":"/home/fanqy/data/Production_3/Data/Config_1/Combine.scp","clipRegion":'null'},
"type":"com.supermap.services.providers.LocalRealspaceProvider",
"name":"local3DCache-Config18"} #发送post请求
headers = {"Content-Type": "application/json"}
response1 = session.post(url1, data=json.dumps(data1), headers=headers)
url2 = 'http://' + host + ':8090/iserver/manager/components.rjson?token=' + token
data2 = {"interfaceNames": "rest",
"name": "3D-local3DCache-Config18",
"providers": "local3DCache-Config18",
"type": "com.supermap.services.components.impl.RealspaceImpl",
"config": {}}
response2 = session.post(url2, data=json.dumps(data2), headers=headers)
if response1.status_code == 200:
created_services = response1.json()
print(created_services)
for service_info in created_services:
print(f"Service Type: {service_info['serviceType']}")
print(f"Service Address: {service_info['serviceAddress']}")
else:
print(f"Failed to create services. Status code: {response1.text}")
if response2.status_code == 200:
created_services = response2.json()
print(created_services)
for service_info in created_services:
print(f"Service Type: {service_info['serviceType']}")
print(f"Service Address: {service_info['serviceAddress']}")
else:
print(f"Failed to create services. Status code: {response2.text}")
报错信息是:Failed to create services. Status code: {
"succeed": false,
"error": {
"code": 400,
"errorMsg": "创建服务提供者的参数为空"
}
}请问应该怎么处理?