Loadrunner简单POST请求

匿名 (未验证) 提交于 2019-12-02 23:32:01

#添加header(有些post请求不需要header)
在需要添加header的地方,1.点击鼠标左键,2.然后选择insert 3.new step 如下图

接着如下图操作

输入参数和值,点击ok,如下图

效果如下,如果要插入多个header的值,则重复以上的值

web_add_header("Access-Token", 		"2333333333333"); 

#添加web_custom_request请求
在需要添加header的地方,1.点击鼠标左键,2.然后选择insert 3.new step 如下图

然后选择web_custom_reques,点击Ok

填些你的请求url,请求方法,请求参数(没有就留空),请求的格式等,如下图

点确定后,自动生成代码,如下图

web_custom_request("web_custom_request", 		"URL=http://pubtest-ht-XXXX.com/api/v1/user/account/get_my_account",//保密问题中间用XXX 		"Method=POST", 		"TargetFrame=", 		"Resource=0", 		"Referer=", 		"EncType=application/json", //规定请求发送前,数据的格式 		"Body=", 		LAST); 

#完成后的完整代码

Action() { 	web_add_header("Access-Token", 		"2333333333333"); 	web_add_header("User-Id", 		"755"); 	web_custom_request("web_custom_request", 		"URL=http://pubtest-xxxx.com/api/v1/user/account/get_my_account",  //保密问题中间用XXX 		"Method=POST", 		"TargetFrame=", 		"Resource=0", 		"Referer=", 		"EncType=application/json", //规定请求发送前,数据的格式 		"Body=", 		LAST);  return 0; } 

点击运行,成功返回结果

Action.c(13):     :292.900000,"today_future_price":0,"today_received_price":0}} Action.c(13): HTML parsing not performed for Content-Type "application/json" ("ParseHtmlContentType" Run-Time Setting is "TEXT"). URL="http://XXXXXX.com/api/v1/user/account/get_my_account"  	[MsgId: MMSG-26548] Action.c(13): web_custom_request("web_custom_request") was successful, 331 body bytes, 171 header bytes  	[MsgId: MMSG-26386] Action.c(26): Notify: Transaction "login" ended with "Pass" status (Duration: 0.5510 Wasted Time: 0.3358). Ending action Action. Ending iteration 1. Ending Vuser... Starting action vuser_end. Ending action vuser_end. Vuser Terminated.``` 
文章来源: https://blog.csdn.net/Anita__Li/article/details/89784926
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!