MQ

  • 1.  Issues using MQ REST API version 9.1.5 when putting message

    Posted Wed June 16, 2021 04:37 PM
    I am trying to put a message using MQ REST API .
    if i use this command : 
    curl -k https://localhost:9443/ibmmq/rest/v1/admin/qmgr/ 
    I get the result saying queue manager is running. 
    C:\Users\bono235>curl -k https://localhost:9443/ibmmq/rest/v2/admin/qmgr/
    {"qmgr": [
    {
    "name": "LNIBI06",
    "state": "running"
    },
    {
    "name": "LNIWI42",
    "state": "running"
    }
    ]}
    So I tried to put a messaging using this command with Content-type: text/plain
    : curl -i -k https://localhost:9443/ibmmq/rest/v1/admin/qmgr/LNIBI06/queue/LokeshTest1/message -X POST -H "ibm-mq-rest-csrf-token: blank" -H "Content-Type: text/plain;charset=utf-8" -d "Hello World!"

    I get error message saying content Type is invalid . Not sure why it did not like the content-type: text/plain

    C:\Users\bono235>curl -k https://localhost:9443/ibmmq/rest/v1/admin/qmgr/LNIBI06/queue/LokeshTest1/message -X POST -H "ibm-mq-rest-csrf-token: blank" -H "Content-Type: text/plain;charset=utf-8" -d "Hello World!"

    {"error": [{
    "action": "Resubmit the request using a valid 'Content-Type' header.",
    "completionCode": 0,
    "explanation": "The REST API request lacked a 'Content-Type' header or contained a 'Content-Type' header which was incorrect.",
    "message": "MQWB0901E: The request did not specify a valid Content-Type. Only \"application/json\" optionally followed by \";charset=UTF-8\" is supported.",
    "msgId": "MQWB0901E",
    "reasonCode": 0,
    "type": "rest"
    }]}


    So i tried using the content Type : application/json:

    C:\Users\bono235>curl  -k https://localhost:9443/ibmmq/rest/v2/admin/qmgr/LNIBI06/queue/LokeshTest1/message -X POST -H "Content-Type: application/json; charset=UTF-8" -d "{"firstName":"John"}"

    {"error": [{
    "action": "Resubmit the request using a valid URI.",
    "completionCode": 0,
    "explanation": "There is no corresponding REST interface on the provided URI.",
    "message": "MQWB0116E: The URI cannot be invoked as it does not correspond to an existing REST interface.",
    "msgId": "MQWB0116E",
    "reasonCode": 0,
    "type": "rest"
    }]}

    I thought maybe I should escape characters for the double quotes in the message and tried this:

    C:\Users\bono235>curl -k https://localhost:9443/ibmmq/rest/v1/admin/qmgr/LNIBI06/queue/LokeshTest1/message -X POST -H "Content-Type: application/json; charset=UTF-8" -d "{\"firstName\":\"John\"}"

    {"error": [{
    "action": "Resubmit the request using a valid URI.",
    "completionCode": 0,
    "explanation": "There is no corresponding REST interface on the provided URI.",
    "message": "MQWB0116E: The URI cannot be invoked as it does not correspond to an existing REST interface.",
    "msgId": "MQWB0116E",
    "reasonCode": 0,
    "type": "rest"
    }]}

    I still get the same error "No corresponding REST interface on the provided URI"

    Can someone guide me what is the correct way to put a message using MQ REST API. 
    Thank you all. 







    ------------------------------
    Lokesh Bonthula
    ------------------------------


  • 2.  RE: Issues using MQ REST API version 9.1.5 when putting message

    Posted Thu June 17, 2021 02:20 AM
    Edited by Neil Casey Thu June 17, 2021 02:22 AM
    Hi Lokesh,

    your problem is with the base URL path you are using for trying to access messages. The base URL path for messages is different to the base URL path for administration.

    The base URL path for messages would be /ibmmq/rest/v1/messaging/ rather than /ibmmq/rest/v1/admin

    So if you try your request using curl -k https://localhost:9443/ibmmq/rest/v1/messaging/qmgr/LNIBI06/queue/LokeshTest1/message -X POST -H "ibm-mq-rest-csrf-token: blank" -H "Content-Type: text/plain;charset=utf-8" -d "Hello World!"

    you might have more luck.

    You can see examples of this URI path in https://www.ibm.com/docs/en/ibm-mq/9.1?topic=api-getting-started-messaging-rest

    Regards


    ------------------------------
    Neil Casey
    Senior Consultant
    Syntegrity Solutions
    Melbourne, Victoria
    IBM Champion (Cloud) 2019-21
    ------------------------------



  • 3.  RE: Issues using MQ REST API version 9.1.5 when putting message

    Posted Fri June 18, 2021 01:03 PM
    It worked after I changed the base url to messaging as per your suggestion.

    Thank you Neil

    ------------------------------
    Lokesh Bonthula
    ------------------------------



  • 4.  RE: Issues using MQ REST API version 9.1.5 when putting message

    Posted Thu June 17, 2021 04:42 AM
    If you have MQ Running with HTTP turned on, then you can get hold of the swagger pages for the API. Point your browser to: https://host:port/ibm/api/explorer

    ------------------------------
    Soheel Chughtai
    ------------------------------



  • 5.  RE: Issues using MQ REST API version 9.1.5 when putting message

    Posted Fri June 18, 2021 06:15 PM
    Thank you Soheel

    ------------------------------
    Lokesh Bonthula
    ------------------------------