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 "">hostname.com/.../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
"">hostname.com/.../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]

 

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