#添加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