Curl代码对python无效
试图从curl变为python
curl --location --request PUT "https://api.getpostman.com/environments/XXXXX-YYYYYY-ZZZZ-BBBB-AAAA-ZZZZZZ?apikey=12334567890" \
--header "Content-Type: application/json" \
--data "{
\"environment\": {
\"values\": [
{\"key\": \"url\", \"value\": \"http://10.12.30.131\"}
]
}
}"
import requests
import json
url = 'https://api.getpostman.com/environments/XXXXX-YYYYYY-ZZZZ-BBBB-AAAA-ZZZZZZ?apikey=12334567890'
header = {"Content-type": "application/json"}
body = '{\"environment\": { \"name\": \"Prod - Deploy\", \"values\": [ {\"key\": \"url\", \"value\": \"http://10.12.30.131\"}]}}'
response = requests.put(url, data=json.dumps(body), headers=header)
print(response.status_code)
print(response.text)
期待200条回复
答案 0 :(得分:0)
主体应为主体='{“ environment \”:{“ name \”:“产品-部署\”,“ values \”:[{“ key \”:“ url \”,“ value \” :“ http://10.12.30.131 \”},{“ key \”:“ appPath \”,“ value \”:“ footytips-apis-v1 \”}]}}''