MQ

Expand all | Collapse all

Issues using MQ REST API version 9.1.5 when putting message

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

    Posted Thu September 02, 2021 08:36 AM
    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/smalan-norge.com -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.

    ------------------------------
    Amy Hadson
    ------------------------------


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

    Posted Thu September 02, 2021 08:45 AM

    The error message "No corresponding REST interface on the provided URI" is telling you that you are using the wrong URI.

    The messaging URI is more like: https://localhost:9443/ibmmq/rest/v1/messaging/qmgr/LNIBI06/queue/LokeshTest1/message

    Note "messaging" in the URL where you have "admin".

    Have a read of this: https://developer.ibm.com/tutorials/mq-develop-mq-rest-api/

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------