提交json串格式的POST请求
Action()
{
web_reg_save_param("retCode",
"LB=retCode\":\"",
"RB=\"",
"NotFound=WARNING",
LAST);
lr_start_transaction("test");
web_add_header("Content-Type" ,"application/json");
web_custom_request("test",
"URL=http://127.0.0.1/test ",
"Method=POST",
"Resource=0",
"Referer=",
"Mode=HTTP",
"EncType=application/json; charset=UTF-8",
"RecContentType=application/json",
"Body={\"channelNo\":\"{channelNo}\",\" phoneno \":12345678900,\"createdTime\":\"{createdTime}\"}",
LAST);
if (!strcmp(lr_eval_string("{retCode}"),"000000"))
{
lr_output_message("Successfull, retcode is:%s", lr_eval_string("{retCode}"));
lr_end_transaction("test ", LR_PASS);
}
else{
lr_error_message("Failed, retcode is:%s", lr_eval_string("{retCode}"));
lr_end_transaction("test ", LR_FAIL);
}
return 0;
}
在编写json串时,注意保证body内容的正确性,字符串必须在\" \"之间,参数名称与参数值之间是:,参数与参数之间用逗号分隔。