node.jsmockingmountebank

How to create multiple imposters in mountebank?


I am new to mountebank and i seeing if i can create multiple imposters in a single post request?

i am using the following request

{
  "imposters": [
    {
      "port": 5150,
      "protocol": "http",
      "recordRequests": true,
      "_links": {
        "self": {
          "href": "http://localhost:2525/imposters/5150"
        }
      }
    },
    {
      "port": 5151,
      "protocol": "http",
      "recordRequests": true,
       "_links": {
        "self": {
          "href": "http://localhost:2525/imposters/5151"
        }
      }
    }
  ]
}

and i am getting an error from mountebank

{
    "errors": [
        {
            "code": "bad data",
            "message": "'protocol' is a required field"
        }
    ]
}

Can anyone help me if i am missign something here?


Solution

  • I suspect the problem is you're using the wrong HTTP method. The way to do that would be to use the PUT command to /imposters instead of POST. See https://www.mbtest.org/docs/api/overview#put-imposters