API requester generation using z/OS Connect build toolkit

1k Views Asked by At

While we generate API requester artifacts using zconbt commandline tool and the API specification file the zconbt is not generating copybooks for multiple error responses. Suppose in the API swagger file we have defined response schema for HTTP codes 200, 400, 500 where the response schema definition is different for each of these responses. Now if we generate the copybooks using zconbt the zconbt ignores the response schema for 400 and 500 and generates the response copybook structure for 200 code only. Now when we invoke this API from MF and get a response with status code 400 and response message as per defined in the swagger for 400 then zcee is not able to transform and send the message back to the MF in a proper copybook variable. This is because the response schema for 400 was already ignored by zconbt in the first place. So my question is do we have a work around to handle this type of scenario where we need to have all the error response schema available via cobol copybooks for handling the the error responses as well.

1

There are 1 best solutions below

2
On

As you have said the API Requester functionality in z/OS Connect EE only provides JSON to COBOL transformation for the success case on an API call.

If the API call completes with something other than the success case, then the response information is returned as-is in the BAQ-RESPONSE-API structure.

Based on the example in the Knowledge Center you could process these responses as follows:

WHEN BAQ-ERROR-IN-API 
    EVALUATE BAQ-STATUS-CODE 
        WHEN 400
            DISPLAY "Invalid Pet ID"
        WHEN 500
            DISPLAY "No pet found with ID "
        WHEN OTHER
            DISPLAY "API returned error " 
                BAQ-STATUS-CODE
    END-EVALUATE

The JSON response is available in the BAQ-STATUS-MESSAGE field and could be parsed using the JSON support in COBOL or PL/I if required.