GET
You can use the HTTP GET method with the
/messaging/qmgr/{qmgrName}/queue/{queueName}/messagelist
resource to get a list of
available messages from the specified queue on the specified queue manager.
Browses a summary list of messages from the specified queue manager and queue. The queue manager must be on the same machine as the mqweb server. The summary data is returned in the HTTP response body as a JSON formatted array. The data does not contain the payload of the messages and is received using the current user context. No messages are removed from the associated queue.
If a request is made to get a list of available messages from a queue that is GET inhibited, an empty JSON array is returned.
Resource URL
https://host:port/ibmmq/rest/v1/messaging/qmgr/{qmgrName}/queue/{queueName}/messagelist
https://host:port/ibmmq/rest/v2/messaging/qmgr/{qmgrName}/queue/{queueName}/messagelist
https://host:port/ibmmq/rest/v3/messaging/qmgr/{qmgrName}/queue/{queueName}/messagelist
- qmgrName
- Specifies the name of the queue manager to connect to for messaging. The queue manager must be on the same machine as the mqweb server.
- queueName
- Specifies the name of the queue from which to browse the messages.
You can use HTTP instead of HTTPS if you enable HTTP connections. For more information about enabling HTTP, see Configuring HTTP and HTTPS ports.
Optional query parameters
- correlationId=hexValue
- Specifies that the HTTP method returns the next message with the corresponding correlation ID.
- correlationId=ID:hexValue or correlationId=application_specific_value
- Specifies that the HTTP method returns a list of messages with the corresponding correlation ID.
- messageId=hexValue
- Specifies that the HTTP method returns the next message with the corresponding message ID.
- messageId=ID:hexValue
- Specifies that the HTTP method returns the next message with the corresponding message ID.
- limit=integerValue
- Specifies that the HTTP method response body is limited to integerValue JSON elements.
Request headers
- Authorization
- This header must be sent if you are using basic authentication. For more information, see Using HTTP basic authentication with the REST API.
- ibm-mq-rest-csrf-token
- This header must be set, but the value can be anything, including being blank.
- Accept-Charset
- This header can be used to indicate what character set is acceptable for the response. If
specified, this header must be set as
UTF-8
. - Accept-Language
- This header specifies the required language for any exceptions or error messages returned in the response message body.
Request body format
None.
Security requirements
The caller must be authenticated to the mqweb server. The MQWebAdmin
and
MQWebAdminRO
roles are not applicable for the messaging REST API. For more information about security for the
REST API, see IBM MQ Console and REST API security.
Once authenticated to the mqweb server the user is capable of using both the messaging REST API and the administrative REST API.
- The queue that is specified by the {queueName} portion of the resource URL,
must be
BROWSE
enabled. - For the queue that is specified by the {queueName}
portion of the resource URL,
+GET
,+INQ
, and+BROWSE
authority must be granted to the security principal of the caller. - For the queue that is specified by the {queueName} portion of
the resource URL,
UPDATE
, access must be granted to the security principal of the caller.
On AIX®, Linux®, and Windows, you can grant authority to security principals to use IBM® MQ resources by using the setmqaut command. For more information, see setmqaut (grant or revoke authority).
On z/OS®, see Setting up security on z/OS.
Response status codes
- 200
- Message list received successfully.
- 400
- Invalid data provided.
- 401
- Not authenticated.
- 403
- Not authorized.
- 404
- Queue does not exist.
- 500
- Server issue or error code from IBM MQ.
- 501
- The HTTP response could not be constructed.
- 502
- The current security principal cannot receive the message as the messaging provider does not support the required function. For example, if the mqweb server class path is invalid.
- 503
- Queue manager not running.
Response headers
- Content-Language
- Specifies the language identifier of the response message in the event of any errors or
exceptions. Used in conjunction with
Accept-Language
request header to indicate the required language for any error or exception conditions. The mqweb server default is used if the requested language is unsupported. - Content-Length
- Specifies the length of the HTTP response body, even when there is no content. The value contains the length of the message data, in bytes.
- Content-Type
- Specifies the type of response body. The value is
application/json;charset=utf-8
.
Response body format
UTF-8
encoded response. The response
contains an outer JSON object that contains a single JSON array called messages
.
Each element in the array is a JSON object that contains information about a message on the queue.
Each element contains the following attributes:- correlationId
- Specifies the correlation ID of the message. The value is returned if the message contains a valid correlation ID.
- correlationId
- Specifies the correlation ID of the message. The value is returned if the message contains a
valid correlation ID. The correlation ID is prefixed with the "
ID:
" string, or can be an application-specific value. - messageId
- Specifies the message ID that is allocated by IBM MQ to this message. It is represented as a 48-character hexadecimal encoded string, representing 24 bytes.
- messageId
- Specifies the message ID that is allocated by IBM MQ to this message. It is represented as a
48-character hexadecimal encoded string, representing 24 bytes. The message ID is prefixed with the
"
ID:
" string. - format
- Specifies the MQMD format field. Under normal circumstances text messages will contain the
IBM MQ
MQSTR
value.
If a request is made to get a list of messages on a queue that is GET inhibited, an empty JSON array is returned.
If an error occurs, the response body contains a JSON formatted error message. For more information, see REST API error handling.
Examples
The following examples use the v2 resource URL. If you
are using a version of IBM MQ earlier than IBM MQ 9.1.5 you must use the v1 resource URL instead. That is, in
the resource URL, substitute v1
where the example URL uses v2
.
mquser
with the password
mquser
. In cURL, the log in request might look like the following Windows example. The LTPA token is stored in the
cookiejar.txt file by using the -c
flag:
curl -k "https://localhost:9443/ibmmq/rest/v2/login" -X POST
-H "Content-Type: application/json" --data "{\"username\":\"mquser\",\"password\":\"mquser\"}"
-c c:\cookiejar.txt
After the user is logged in, the LTPA token and ibm-mq-rest-csrf-token
HTTP
header are used to authenticate further requests. The ibm-mq-rest-csrf-token
token_value
can be any value, including blank.
- The following Windows cURL example lists the next ten
available messages from queue
Q1
on queue managerQM1
, using default options:curl -k "https://localhost:9443/ibmmq/rest/v2/messaging/qmgr/QM1/queue/Q1/messagelist" -X GET -b c:\cookiejar.txt -H "ibm-mq-rest-csrf-token: token-value" -H "Accept: application/json"
- The following Windows cURL example lists the next two
hundred available messages from queue
Q1
on queue managerQM1
, using default options:curl -k "https://localhost:9443/ibmmq/rest/v2/messaging/qmgr/QM1/queue/Q1/messagelist?limit=200" -X GET -b c:\cookiejar.txt -H "ibm-mq-rest-csrf-token: token-value" -H "Accept: application/json"
- The following Windows
cURL example lists only those messages with the corresponding correlation ID,
0000000000000000000000000000000000000000abcdabcd
, from queueQ1
on queue managerQM1
:curl -k "https://localhost:9443/ibmmq/rest/v2/messaging/qmgr/QM1/queue/Q1/messagelist?correlationId=0000000000000000000000000000000000000000abcdabcd" -X GET -b c:\cookiejar.txt -H "ibm-mq-rest-csrf-token: token-value" -H "Accept: application/json"
-
The following Windows cURL example is the same as the previous example, but uses REST API V3. The example lists only those messages with the corresponding correlation ID,
0000000000000000000000000000000000000000abcdabcd
, from queueQ1
on queue managerQM1
:curl -k "https://localhost:9443/ibmmq/rest/v3/messaging/qmgr/QM1/queue/Q1/messagelist?correlationId=ID:0000000000000000000000000000000000000000abcdabcd" -X GET -b c:\cookiejar.txt -H "ibm-mq-rest-csrf-token: token-value" -H "Accept: application/json"