REST API error handling
The REST API reports errors by returning an appropriate HTTP response code, for example 404 (Not Found), and a JSON response. Any HTTP response code that is not in the range 200 - 299 is considered an error.
The error response format
The response is in JSON format in UTF-8 encoding. It contains nested JSON objects:
- An outer JSON object that contains a single JSON array called error.
- Each element in the array is a JSON object that represents information about an error. Each JSON object contains the following properties:
- type
- String.
- messageId
- String.
- message
- String.
- explanation
- String.
- action
- String.
- qmgrName
- This field is only available for z/OS where the queue manager is a member of the queue sharing group. We must have specified the commandScope optional query parameter, or the queueSharingGroupDisposition attribute.
- completionCode
- This field is only available when type is pcf, java, or rest.
- reasonCode
- This field is only available when type is pcf, java, or rest.
- exceptions
- This field is only available when type is java.
Errors with queue sharing groups
In a queue sharing group, it is possible to specify an optional query parameter of commandScope for certain commands. This parameter allows the command to be propagated to other queue managers in the queue sharing group. Any one of these commands can fail independently, resulting in some commands succeeding and some commands failing for the queue sharing group.
In cases where a command partially fails, an HTTP error code of 500 is returned. For each queue manager that generated a failure, information on that failure is returned as an element in the error JSON array. For each queue manager that successfully ran the command, the name of the queue manager is returned as an element in a success JSON array.
Examples
- The following example shows the error response to an attempt to get information about a queue manager that does not exist:
"error": [ { "type": "rest", "messageId": "MQWB0009E", "message": "MQWB0009E: Could not query the queue manager 'QM1'", "explanation": "The MQ REST API was invoked specifying a queue manager name which cannot be located.", "action": "Resubmit the request with a valid queue manager name or no queue manager name, to retrieve a list of queue managers. " } ]- The following example shows the error response to an attempt to delete a queue in a queue sharing group that does not exist for some queue managers:
"error" : [ { "type": "rest", "messageId": "MQWB0037E", "message": "MQWB0037E: Could not find the queue 'missingQueue' - the queue manager reason code is 3312 : 'MQRCCF_UNKNOWN_OBJECT_NAME'", "explanation": "The MQ REST API was invoked specifying a queue name which cannot be located.", "action": "Resubmit the request with the name of an existing queue, or with no queue name to retrieve a list of queues.", "qmgrName": "QM1" }, { "type": "rest", "messageId": "MQWB0037E", "message": "MQWB0037E: Could not find the queue 'missingQueue' - the queue manager reason code is 3312 : 'MQRCCF_UNKNOWN_OBJECT_NAME'", "explanation": "The MQ REST API was invoked specifying a queue name which cannot be located.", "action": "Resubmit the request with the name of an existing queue, or with no queue name to retrieve a list of queues.", "qmgrName": "QM2" } ], "success" : [{"qmgrName": "QM3"}, {"qmgrName": "QM4"}]
Errors with MFT requests
If MFT REST API services are not enabled, and you invoke the MFT REST API, you receive the following exception:{"error": [{ "action": "Enable the Managed File Transfer REST API and resubmit the request.", "completionCode": 0, "explanation": "Managed File Transfer REST calls are not permitted as the service is disabled.", "message": "MQWB0400E: Managed File Transfer REST API is not enabled.", "msgId": "MQWB0400E", "reasonCode": 0, "type": "rest" }]}If MFT REST API services are enabled and the coordination queue manager is not set in the mqwebuser.xml file, you receive the following exception:{"error": [{ "action": "Set the coordination queue manager name and restart the mqweb server.", "completionCode": 0, "explanation": "Coordination queue manager name must be set before using Managed File Transfer REST services.", "message": "MQWB0402E: Coordination queue manager name is not set.", "msgId": "MQWB0402E", "reasonCode": 0, "type": "rest" }]}Parent topic: Administration using the REST API