Highlighted
Absent Member.
Absent Member.
1461 views

Capturing the dynamic value from a Json script response body using web_reg_save_param. - This threa

I'm unable to capture the value of the voucherId variable which is present in the Json script response body.

The encoding type used is application/json; charset=UTF-8, Recording Mode-HTML.
Given below is the web_reg_save_param which I've used in the script.

web_reg_save_param("VID",
"LB=\"voucherId\":",
"RB=,",
LAST)

The following messages are displayed in the Replay Log.

Action.c(35): Warning: The string 'VID' with parameter delimiters is not a parameter.

Action.c(35): HTML parsing not performed for Content-Type "application/json" ("ParseHtmlContentType" Run-Time Setting is "TEXT"). URL="http://xx.xx.xx.xxx:xxxx/babeslol/move.action?voucherID={VID}"

Given below is the response body where the variable can be found(Generation Log).
{"response": {"status":true , "reservation":"{\x5C"advancedPayments\x5C":[],\x5C"arrivalDate\x5C":\x5C"01\x5C\x5C\x5C/12\x5C\x5C\x5C/2010\x5C",\x5C"arrivalTime\x5C":\x5C"12:00\x5C",\x5C"bookingType\x5C":\x5C"NORMAL\x5C",\x5C"changeReasonId\x5C":null,\x5C"departureDate\x5C":\x5C"12\x5C\x5C\x5C/12\x5C\x5C\x5C/2010\x5C",\x5C"voucherId\x5C":353, \x5C"voucherVersion\x5C":0}"}}

Following is part of the response body taken from firebug for the same transaction.
\"voucherId\":400,\"voucherVersion\":0}"}}

Why can't I capture the voucherId value from the web_reg_save_param I've mentioned in the script?

Thank you,
0 Likes
4 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Capturing the dynamic value from a Json script response body using web_reg_save_param. - This threa

Should it not be:

web_reg_save_param("VID",
"LB=voucherId\\x5C\":",
"RB=,",
LAST)
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Capturing the dynamic value from a Json script response body using web_reg_save_param. - This threa

Nope, that didn't work.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Capturing the dynamic value from a Json script response body using web_reg_save_param. - This threa

Why have you used two backslashes in-front of x5C?(Is it an error? or Is it because it needs to be escaped?).

Thank you,
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Capturing the dynamic value from a Json script response body using web_reg_save_param. - This threa

I placed a back slash there so that the one before the x5C would be recognized.

Before: voucherId\x5C":

After: voucherId\\x5C\":

That should have picked it up.

Could you paste the code here for the section of the script where you use the web_reg_save_param ro capture the value?

Actually it would be better to see the output of the entire script after playing it back with full logging if possible.

Alan
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.