Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

returnStatus example for creating a responder using the REST API

I have a process that creates message responders using the REST API. To date, I have always used the default values for the returnStatus portion of the request. All of my users have only needed an HTTP 200 response. Now I have a new request to allow custom return status codes, e.g. 201 Created, or 401 Unauthorized, etc.

Can you give me an example of how I would use those values in the request JSON for /tools/messageResponders POST?

Thanks,

JT

Comments

  • williammccusker
    williammccusker Posts: 539 ✭✭✭

    Hi,

    I would recommend taking a look at the REST API page on the server, it should have a default structure that shows all the available fields.

    It can be found at http://:/soavirt/api

    This is the relevant field and its children that you are looking for. The field "options" I believe is a child of the root object. There are two parts, the message and the status code. Depending on how your server is deployed the message may or may not be supported but the status code always works every where.

    Let me know if this helped!

    "options": {
        "returnStatus": {
          "useDefault": false,
          "message": {
            "type": "fixed",
            "fixed": "HTTP MESSAGE"
          },
          "status": {
            "type": "fixed",
            "fixed": "401"
          }
        }
    }
    
  • jefftuckerbofa
    jefftuckerbofa Posts: 117

    Thanks, I saw this in the API docs, but I wasn't exactly sure how the values fit. What you have posted makes perfect sense. Thanks once again for making me look good here at the bank. ;-) JT

  • williammccusker
    williammccusker Posts: 539 ✭✭✭

    Happy to help! :smile: