Lisa-test-invoke API doesn't provide the plain text response
search cancel

Lisa-test-invoke API doesn't provide the plain text response

book

Article ID: 226750

calendar_today

Updated On:

Products

CA Application Test

Issue/Introduction

The Lisa invoke API  call gives encoded response instead of the plain text response. Is there a way to see the plain text response?

For example, the API call http://lisa-registryxxx.com/lisa-test-invoke/api/v1/tests/reports/3344444444462140A80C7/cycles/2321345B0B11ECBA2A327C44B1F1F4 shows the below response:

{
        "stepGUID": "E1A4CDA7FA0011EBB4D53E2EFFAD6698",
        "stepName": "Success Log Message",
        "type": "STEP",
        "errorCount": "0",
        "warningCount": "0",
        "quite": "false",
        "startTime": "2021-09-21T18:40:06+0000",
        "endedState": "PASSED",
        "endedStateValue": "0",
        "stacktrace": null,
        "stepCommand": {
          "request": null,
          "response": "VGVzdCBjYXNlIElEID0gQ0JfMDAxClRlc3QgY2FzZSBEZXNjID0gU2VuZEFQSQpUZXN0IGNhc2UgU2V2ZXJpdHkgPSBDcml0aWNhbApTdGF0dXM9UEFTU0VE",
          "requestBase64Encoded": null,
          "responseBase64Encoded": "true"
        },

Expected plain text like below 

Test case ID = Rover
Test case Desc = SendAPI
Test case Severity = Critical
Status=PASSED

Environment

Release : 10.x

Component : DevTest API

Cause

Encoded response is by design.

Resolution

By design, Lisa-Test-Invoke API returns Base64 Encoded response and there is no property which can be configured to get the plain text response. This is by design.

Below information will answer why the API responses are Base64 Encoded.

1.All our DEVTEST APIs return a JSON response
 
2. As per the JSON standard, any string that is not friendly to be wrapped inside the JSON should be Base64 encoded. This applies to Strings the contain any of the following special characters:
* - char - any Unicode character except " or \ or control character (ASCII < 20)* - \"* - \\* - \/* - \b* - \f* - \n* - \r* - \t* - \u0000
 
3. It doesn't matter if the String is valid XML or valid JSON itself. Any string that contains any of the special characters listed about cant be part of the JSON as it is. It either has to be escaped or Base64 Encoded. Escaping is very tedious for the consumer as they have to very very carefully un-escape it. The recommended practice, also the one that we follow is to Base 64 Encode it.
 
A JSON value cannot be part of the response of ANY Test Invoke API (http://localhost:1505/lisa-test-invoke/api/v1). The simple reason being the presence of double quotes " in the JSON string. As explained already, any request/response string in the TEST INVOKE API response which contains any of the following characters will be simply Base64 Encoded. Whenever we encode, we add flags to let the consumer understand that the value needs to be Base64 Decoded. (requestBase64Encoded, responseBase64Encoded). This is a standard practice. 
  • Backspace
  • Form feed 
  • Newline 
  • Carriage return 
  • Tab 
  • Double quote 
  • Backslash

 

Additional Information

If a plain text response is expected then write a wrapper to encode the Base64 response as a workaround.