0
Iam在一个需要指定多个表单参数的项目上工作,其中一个是文件本身。如何在请求中发送多个表单参数?
我的尝试:
import requests
REST_URL = 'http://192.168.150.138:8888/tasks/create/file'
with open(os.path.join('/home/default/Batch/Samples/', filename),'rb') as sample:
files = {'file' :("temp_file_name" , sample)}
r = requests.post(REST_URL , files=files)
问题:
我需要通过这样的附加信息(这些都是形式参数)
file (required) - sample file (multipart encoded file content)
package (optional) - analysis package to be used for the analysis
timeout (optional) (int) - analysis timeout (in seconds)
priority (optional) (int) - priority to assign to the task (1-3)
options (optional) - options to pass to the analysis package
machine (optional) - label of the analysis machine to use for the analysis
platform (optional) - name of the platform to select the analysis machine from (e.g. “windows”)
假设,如果我想以这种形式发送机器名称,我可以像这样创建吗?
data = {'machine' :'machine_name'}
r =requests.post(EST_URL , files=files,data=data)
任何建议将有所帮助。
是,导入请求 –
@ DAS-G型修正 –