Highlighted
Contributor.
Contributor.
204 views

web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Hi All,

I am writing a script in VUgen to call rest api and trying to store one of the values from response.

And trying to pass this parameter value to next subsequent APIs call. However, when I am trying to print or pass this parameter value to next call, this value is coming as timestamp instead of actual value.

Can someone help me to fix this issue? Thanks in advance.

 

web_reg_save_param_ex(
        "ParamName=Read_Response",
        "LB=",
        "RB=",
        SEARCH_FILTERS,
        "Scope=Body",
        LAST);
      
      web_reg_save_param_json(
        "ParamName=nameParam",
        "QueryString=$..@researchID",
        "SEARCH_FILTERS",
        "Scope=Body", 
        "SelectAll=Yes",
        "LAST");
      
      web_rest("GET: Rest API Request",
        "URL=https://******/research",
        "Method=GET",
        "Snapshot=t769333.inf",
        HEADERS,
        "Name=ID", "Value=LB", ENDHEADER,
        "Name=TRANSIT", "Value=22", ENDHEADER,
        "Name=APPLICATION-ID", "Value=2003", ENDHEADER,
        "Name=Content-Type", "Value=application/json", ENDHEADER,
        LAST);
    
    
      lr_output_message("Value for Read_Response is %s ", lr_eval_string("{Read_Response}"));
      lr_output_message("Value for Research id is %s ", lr_eval_string("{nameParam_1}"));
      lr_output_message("Value for Research id count %s ", lr_eval_string("{nameParam_count}"));

 

Response of API:

{
"operationMetaData": {
"context": {
"transactionID": "727733",
"timeStamp": 1591654282347
},
"status": [
{
"statusCode": "200-001",
"message": "Transaction Processed Successfully"
}
]
},
"@researchID": "22057",
"status": "2",
"lastChanged": {
"Agent": {
"ID": "LB",
"BranchID": 22,
"AuthorizationLevel": null
},
"ModificationTimeStamp": 1591652921630
}
}

Output:

PCR.c(27): Notify: Saving Parameter "Read_Response = {"operationMetaData":{"context":

PCR.c(27): Notify: Saving Parameter "nameParam_1 = 22057".
PCR.c(27): Notify: Saving Parameter "nameParam_count = 1".
PCR.c(27): web_rest highest severity level was "warning", 370 body bytes, 154 header bytes, 13 chunking overhead bytes [MsgId: MMSG-26387]
PCR.c(39): Value for PCE_Read_Response is {PCE_Read_Response} [Time:2020-06-08 14:11:22]
PCR.c(40): Value for Research id is {nameParam_1} [Time:2020-06-08 14:11:22]
PCR.c(41): Value for Research id count {nameParam_count} [Time:2020-06-08 14:11:22]

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Actually, I see these brackets in your script:

ParamLeftBrace=<
ParamRightBrace=>

LeonidPekel_0-1591713053185.png

So you should update your code as below:

    
    lr_output_message("Value for PCEGET_Read_Response is %s ", lr_eval_string("<PCEGET_Read_Response>"));
    lr_output_message("Value for Research id is %s ", lr_eval_string("<nameParam_1>"));
    lr_output_message("Value for Research id count %s ", lr_eval_string("<nameParam_count>"));
    

Regards,

Leonid

View solution in original post

0 Likes
9 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Hi, 

Timestamp value at the end of the log messages appears as  result of enabling "Print timestamp for 'Message Functions' option in RTS  (General > Log). Uncheck this option and the log messages will include only the message itself.

Please, make sure that you use the exact parameters names in lr_output_message functions.

I ran emulation of your code:

web_reg_save_param_ex(
        "ParamName=Read_Response",
        "LB=",
        "RB=",
        SEARCH_FILTERS,
        "Scope=Body",
        LAST);
      
      web_reg_save_param_json(
        "ParamName=nameParam",
        "QueryString=$..@researchID",
        "SEARCH_FILTERS",
        "Scope=Body", 
        "SelectAll=Yes",
        "LAST");
      
      web_rest("GET: Rest API Request",
        "URL=....",
        "Method=GET",
        ...
        LAST);
    
       lr_output_message("Value for Read_Response is %s ", lr_eval_string("{Read_Response}"));
      lr_output_message("Value for Research id is %s ", lr_eval_string("{nameParam_1}"));
      lr_output_message("Value for Research id count %s ", lr_eval_string("{nameParam_count}"));

  and got the following in the replay log:

Action.c(20): Notify: Saving Parameter "Read_Response = {"operationMetaData": {"context": {"transactionID": "727733","timeStamp": 1591654282347},"status": [{"statusCode": "200-001","message": "Transaction Processed Successfully"}]},"@researchID": "22057","status": "2","lastChanged": {"Agent": {"ID": "LB","BranchID": 22,"AuthorizationLevel": null},"ModificationTimeStamp": 1591652921630}}".

Action.c(20): Notify: Saving Parameter "nameParam_1 = 22057".
Action.c(20): Notify: Saving Parameter "nameParam_count = 1".

Action.c(27): Notify: Parameter Substitution: parameter "Read_Response" = "{"operationMetaData": {"context": {"transactionID": "727733","timeStamp": 1591654282347},"status": [{"statusCode": "200-001","message": "Transaction Processed Successfully"}]},"@researchID": "22057","status": "2","lastChanged": {"Agent": {"ID": "LB","BranchID": 22,"AuthorizationLevel": null},"ModificationTimeStamp": 1591652921630}}"
Action.c(27): Value for Read_Response is {"operationMetaData": {"context": {"transactionID": "727733","timeStamp": 1591654282347},"status": [{"statusCode": "200-001","message": "Transaction Processed Successfully"}]},"@researchID": "22057","status": "2","lastChanged": {"Agent": {"ID": "LB","BranchID": 22,"AuthorizationLevel": null},"ModificationTimeStamp": 1591652921630}} [Time:2020-06-08 22:12:09]
Action.c(28): Notify: Parameter Substitution: parameter "nameParam_1" = "22057"
Action.c(28): Value for Research id is 22057 [Time:2020-06-08 22:12:09]
Action.c(29): Notify: Parameter Substitution: parameter "nameParam_count" = "1"
Action.c(29): Value for Research id count 1 [Time:2020-06-08 22:12:09]

Best regards,

Leonid.

0 Likes
Highlighted
Contributor.
Contributor.

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Thanks Leonid, I am using the same code which you have currently tested but I am seeing output as below.

Am I need to declare these varaibles at start of the script? Please advise.

web_reg_save_param_ex(
        "ParamName=Read_Response",
        "LB=",
        "RB=",
        SEARCH_FILTERS,
        "Scope=Body",
        LAST);
      
      web_reg_save_param_json(
        "ParamName=nameParam",
        "QueryString=$..@researchID",
        "SEARCH_FILTERS",
        "Scope=Body", 
        "SelectAll=Yes",
        "LAST");

 

PCR.c(27): Notify: Saving Parameter "nameParam_1 = 20963".
PCR.c(27): Notify: Saving Parameter "nameParam_count = 1".
PCR.c(27): web_rest highest severity level was "warning", 371 body bytes, 154 header bytes, 13 chunking overhead bytes [MsgId: MMSG-26387]
PCR.c(39): Value for PCE_Read_Response is {Read_Response}
PCR.c(40): Value for Research id is {nameParam_1}
PCR.c(41): Value for Research id count {nameParam_count}

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Hi,

Parameters in LoadRunner are not variables and should not be declared.

Is it possible to send me your script (just without server details)? 

Probably message text in the log is not the same as you specified in the original post...

lr_output_message("Value for Read_Response is %s ", lr_eval_string("{Read_Response}"));
lr_output_message("Value for Research id is %s ", lr_eval_string("{nameParam_1}"));
lr_output_message("Value for Research id count %s ", lr_eval_string("{nameParam_count}"));

PCR.c(39): Value for PCE_Read_Response is {Read_Response}
PCR.c(40): Value for Research id is {nameParam_1}
PCR.c(41): Value for Research id count {nameParam_count}

Another question is about parameter's brackets?

Could you, please, verify that left and right delimiters are {}? 
You can check that in Vugen Tools > Options > Scripting > Parameters.

Regards,

Leonid.

 

0 Likes
Highlighted
Contributor.
Contributor.

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

char *strTransName;

PCR(){

strTransName = lr_eval_string("HARTS_JSON_PCE");

lr_start_transaction(strTransName);

web_reg_save_param_ex(
"ParamName=PCE_Read_Response",
"LB=",
"RB=",
SEARCH_FILTERS,
"Scope=Body",
LAST);

web_reg_save_param_json(
"ParamName=nameParam",
"QueryString=$..@researchID",
"SEARCH_FILTERS",
"Scope=Body",
"SelectAll=Yes",
"LAST");

web_rest("GET: VTI PCE Request",
"URL=<URL>",
"Method=GET",
"Snapshot=t769333.inf",
HEADERS,
"Name=OPERATOR-ID", "Value=LB", ENDHEADER,
"Name=REQUEST-TRANSIT", "Value=22", ENDHEADER,
"Name=CONSUMER-APPLICATION-ID", "Value=2003", ENDHEADER,
"Name=Content-Type", "Value=application/json", ENDHEADER,
LAST);


lr_output_message("Value for PCE_Read_Response is %s ", lr_eval_string("{PCE_Read_Response}"));
lr_output_message("Value for Research id is %s ", lr_eval_string("{nameParam_1}"));
lr_output_message("Value for Research id count %s ", lr_eval_string("{nameParam_count}"));

lr_end_transaction(strTransName, LR_PASS);

return 0;

}

0 Likes
Highlighted
Contributor.
Contributor.

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Hi Leo, I also checked Vugen Tools > Options > Scripting > Parameters. Its {}.

Thanks.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Hi,

Could you, please, validate parameters delimiters for your desired script?

From Vugen menu (Design > Parameters > Configure parameter delimiters ) or settings inside script USR-file.

ParamLeftBrace={
ParamRightBrace=}

To check the issue from our side I need the whole script folder (please, hide your server details and export the script to ZIP file, Runtime files only).

Thanks,

Leonid

0 Likes
Highlighted
Contributor.
Contributor.

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Hi Leo, good morning.

Here is the setting from Vugen menu (Design > Parameters > Configure parameter delimiters.

ParamLeftBrace={
ParamRightBrace=}

And, I am attaching complete script folder by removing URL. Kindly advise further and your help is much appreciated.

 

Thanks.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Actually, I see these brackets in your script:

ParamLeftBrace=<
ParamRightBrace=>

LeonidPekel_0-1591713053185.png

So you should update your code as below:

    
    lr_output_message("Value for PCEGET_Read_Response is %s ", lr_eval_string("<PCEGET_Read_Response>"));
    lr_output_message("Value for Research id is %s ", lr_eval_string("<nameParam_1>"));
    lr_output_message("Value for Research id count %s ", lr_eval_string("<nameParam_count>"));
    

Regards,

Leonid

View solution in original post

0 Likes
Highlighted
Contributor.
Contributor.

Re: web_reg_save_param_json - param value is printing as timestamp, help needed.

Jump to solution

Thanks Leo, you made my day. 🙂

Issue has been fixed and am able to extract the parameters.

 

PCEAPI.c(38): Notify: Parameter Substitution: parameter "nameParam_1" = "19758"
PCEAPI.c(38): Value for Research id is 19758
PCEAPI.c(39): Notify: Parameter Substitution: parameter "nameParam_count" = "1"
PCEAPI.c(39): Value for Research id count 1
PCEAPI.c(41): Notify: Transaction "HARTS_JSON_PCEGET" ended with a "Pass" status (Duration: 1.6201 Wasted Time: 1.2413).

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.