The request content was malformed:
Unrecognized token 'contentType': was expecting ('true', 'false' or 'null')
req = requests.post(url_post, headers=headers, cookies=cookies, data=data, verify=False)
这是因为在调用时输入的参数格式不对!修改为:
req = requests.post(url_post, headers=headers, cookies=cookies, data=json.dumps(data), verify=False)
url_post = 'http://172.16.5.12:1065/api/itoa/splquery/common'
data = {
"content": "start=now-168h | metric=FILESYSTEM.FSCapacity ip=\"144.240.208.87_145.240.208.87\" instance=\"/ORONLAPS\" | stats max by 30m,ip,instance",
"contentType": "text", "uriPath": "/rest/metric/_q", "httpMethod": "post"}
# data = json.dumps(data)
req = requests.post(url_post, headers=headers, cookies=cookies, data=data, verify=False)
# res = req.text
# print(res)
print(req.status_code)