1
http請求我想打一個http請求如在下面的curl命令這兩個值和文件:如何給表單的PARAM,在蟒蛇
curl -X PUT \
https://anypoint.mulesoft.com/cloudhub/api/v2/applications/highfiles \
-H 'authorization: Bearer XXX' \
-H 'cache-control: no-cache' \
-H 'content-length: 0' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-H 'host: anypoint.mulesoft.com' \
-H 'postman-token: XXX' \
-H 'x-anypnt-env-id: XXX' \
-H 'x-anypnt-org-id: XXX' \
-F 'appInfoJson={
"muleVersion": {
"version": "3.8.5"
},
"properties":{"env":"dev"}
}'
我曾嘗試下面的請求,但都徒勞
files = {'file': open('C:\Users\\highfiles.zip', 'rb')}
appInfoJson1 = {
"muleVersion": {
"version": "3.8.5"
},
"properties": {"env":"dev1"}
}
print dict(appInfoJson=appInfoJson1)
headers = {"X-ANYPNT-ORG-ID": "XXXX",
"X-ANYPNT-ENV-ID": "XXXX",
"Authorization": "Bearer " + access_token,
}
response = requests.put("https://anypoint.mulesoft.com/cloudhub/api/v2/applications/highfiles",
data=dict(appInfoJson=appInfoJson1) , files=files, headers = headers)
如何在python http請求中提供表單參數值和文件。