我在第97页有一个REST API documentation,它给了我下面这样的rest api片段:
我对python也做了同样的事情。见下文:
import requests
base_url = 'https://hostname/api'
session = requests.Session()
headers = {
'Content-Type' : 'application/json',
'cache-control': 'no-cache',
'x-endeavour-sessionid': '23423423werfer23f23rf2'
}
_params = {
"resourceType": "vm",
"from": "hlo",
"filter": {
[
{
"property": "storageProfileName",
"value": "testname",
"op": "="
}
]
}
}
_data = f'''{{
"name": "*",
"hypervisorType": "vmware"
}}'''
url_unprotectedvm = base_url + '/hypervisor/search'
unprotectedvm_data = session.post(url_unprotectedvm, params=_params, data=_data, headers=headers, verify=False)
print(unprotectedvm_data)
但是我在第"op": "="
行中得到了一个TypeError: unhashable type: 'list'
。我签出了所有未损坏的类型列表帖子,并尝试将列表更改为元组。但随后API抛出400个错误请求。这是API的问题还是我做错了什么
{}包含dict not列表。您应该尝试删除筛选器中的{}
相关问题 更多 >
编程相关推荐