Highlighted
New Member.
321 views

Saving parameters for non-200 responses

 

I have a REST service which uses HTTP response codes for different statuses. I need to save the value from a response even if the HTTP response code is not 200. I've tried both of the below and both work fine when the response is 200, but LR seems to not even recognize the body exists if the response is 404. Does anyone have any experience with this or any suggestions on how to proceed?

web.regSaveParamJson({
	paramName:"CALL_STATUS",
	queryString:"$.success",
	scope: "Body",
	contentType: "application/json; charset=utf-8"
});

web.regSaveParamRegexp({
	paramName:"CALL_STATUS2",
	regExp:'(.*)',
	group: 1,
	scope: "Body"
});
GetOutages.js(26): t=26393ms: 116-byte DECODED response body for "https://hostname.com/outage/query"
(RelFrameId=1, Internal ID=6)
GetOutages.js(26): {"success":false,"meta":{"code":"FN-ACCT-NOTFOUND","description":"","context":
"005QxkNAnfz4yk4_rT4EyY0006Fx000287"}}
GetOutages.js(26): Warning -26627: HTTP Status-Code=404 (Not Found) for
"https://hostname.com/outage/query" [MsgId: MWAR-26627]

GetOutages.js(26): Notify: Saving Parameter "CALL_STATUS = ".
GetOutages.js(26): Continuing after Error -35060: No matches were found for the specified query:
"$.success" [MsgId: MERR-35060] [Time:2018-05-10 11:58:30]
GetOutages.js(26): Notify: Saving Parameter "CALL_STATUS2 = ".
GetOutages.js(26): Continuing after Error -35049: No match found for the requested parameter "CALL_STATUS2".
Check whether the requested regular expression exists in the response data [MsgId: MERR-35049]

 

0 Likes
1 Reply
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: Saving parameters for non-200 responses

Not sure if this behavior is by design, should be described in the PDF manuals.

I noticed that the API for asynchronous calls has callback functions that seems to receive all data 'header', 'body' and httpResponseCode. See the help at 'Response Callback'. It is not straight forward to use, but might be a route to go forward.

Signature:
Reward community members who take time to respond and help.
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.