requests接口自动化6-Body里json格式数据形式的post请求:json

时间:2022-09-17 07:10:33

Body里json格式数据形式的post请求:用json传参

fiddler里请求响应内容:

requests接口自动化6-Body里json格式数据形式的post请求:json

传递的json数据

[{"stepId":"0","caseId":"3","projectId":"2","stepPath":"/login","stepOperation":"HttpClientPost","stepParameters":"username","action":"www","expectedResult":"ok","stepType":"0","extend":"1"}]

  

代码:

#body数据为json格式的post请求,用json传参,支持json对象,json数组

json1=[{"stepId":"0","caseId":"3","projectId":"2","stepPath":"/login","stepOperation":"HttpClientPost","stepParameters":"username","action":"www","expectedResult":"ok","stepType":"0","extend":"1"}]
response6=s.post("http://www.luckyframe.cn/testmanagmt/projectCaseSteps/editSave",json=json1)
print('传json的请求:',response6.text)

  运行结果:

传json的请求: {"msg":"操作成功","code":0}