LoadRunner使用web_reg_save_param_ex获取token匹配不到的问题

LoadRunner使用web_reg_save_param_ex获取token匹配不到的问题

问题描述:

使用web_reg_save_param_ex获取登录接口返回的token值:

web_reg_save_param_ex(
    "ParamName=token",
    "LB={\"access_token\":\"",
    "RB=\",\"token_type",
    "Ordinal=1",
    SEARCH_FILTERS,
    "Scope=BODY",
    LAST);

lr_output_message("token");

登录接口返回的token格式如下:
{"access_token":"61714d0a-777c-4208-98a5-b4d8a10fe19c","token_type":"bearer","refresh_toke
Action.c(26): n":"ac88f5bd-0079-476f-bfa5-dda4c5045cc8","expires_in":4894,"scope":"all"}

从web_reg_save_param_ex看左右边界都存在,但回放就是显示Error -26377: No match found for the requested parameter "token". Check whether the requested boundaries exist in the response data.
到底哪里出了问题?

img

img

终于解决了,调换了一下位置就能成功回放了,把web_reg_save_param_ex放在登录接口上方,再把web_add_auto_header放在登录接口下方,就能成功获取到token并把它添加到请求头部。

img