Create Virtual Services

To create a Virtual Service in your workspace, you need to know your Workspace identifier. The sample code uses a workspaceId of 123456. Use the actual ID value of your Workspace.

The response contains a Virtual Service identifier that you should note down. You will need this serviceMockId when you want to configure, deploy, or delete this Virtual Service later.

The easiest way to create a Virtual Service is through the web interface, where you can upload an existing Swagger file, HAR file, WireMock stubs, or MockLab stubs.
 

Minimum Parameters for creating a Virtual Service

The following parameters are the base parameters required to create a Virtual Service.

Create a Virtual ServiceMinimum Configuration Sample


curl 'https://mock.blazemeter.com/api/v1/workspaces/123456/service-mocks' \
  -X POST \
  -H 'accept: application/json;charset=UTF-8' \
  -H 'Content-Type: application/json' \
  -d '{ "description": "string", "endpointPreference": "string", "harborId": "string", "id": 0, "type": "TRANSACTIONAL", "liveSystemHost": "string", "liveSystemPort": 0, "name": "string", "noMatchingRequestPreference": "string", "noMatchingRequestTxnId": 0, "serviceId": 123, "shipId": "string", "thinkTime": 0, "mockServiceTransactions": [ {"txnId":1, "priority":9} ]}'

Create a Virtual Service Request Attributes

Attributes

  • descriptionstring

    The description of the new Virtual Service.

  • endpointPreferencestring

    Choose HTTP or HTTPS.

  • typestring

    Set the type to "TRANSACTIONAL" for transactional Virtual Services. The legacy value "SV" for DevTest MAR Mock Services is deprecated.

  • harborIdstring

    This identifier was used in MAR-based Mock Services (EOL) only. The identifier of the private on-premise location (aka 'harbor'), a logical container on the BlazeMeter end that contains one or more agents (aka 'ships') on your end.

  • liveSystemHoststring

    The host of the live system.

  • liveSystemPortinteger

    The port of the live system.

  • namestring

    The name of the new Virtual Service.

  • noMatchingRequestPreferencestring

    What to do if there are no matching requests. Choose either return404 to return "no match found", or choose bypasslive to redirect to the live system.

  • noMatchingRequestTxnIdinteger

    If there are no matching requests, this is the Transaction ID that did not match.

  • serviceIdinteger

    The identifier of an existing Service that contains this Virtual Service.

  • shipIdstring

    This identifier was used in MAR-based Mock Services (EOL) only. The identifier of a 'ship', an agent in a logical container on the BlazeMeter end in your private on-premise location (aka 'harbor').

  • thinkTimeinteger

    Think time is a synthetic delay inserted between test steps to ensure the test script moves at a human pace.

  • mockServiceTransactionsarray

    The Transaction identifiers that are assigned to this Virtual Service, as a list of {"txnId":1,"priority":9} entries. The field `txnId` is the identifier of an existing transaction that belongs to this service mock. The field `priority` is an integer value from 1 to 10 inclusive, where a lower number represents the desire to match the request first. You can leave the list empty and assign Transactions later.

  •  

Response201 Created

{
  "apiVersion": 0,
  "error": "string",
  "errors": [
    {
      "code": "string",
      "message": "string",
      "severity": "WARN"
    }
  ],
  "limit": 0,
  "link": "string",
  "requestId": "string",
  "result": {
    "created": "2020-06-17T13:04:42.949Z",
    "createdBy": "string",
    "createdDate": "string",
    "description": "string",
    "endpointPreference": "string",
    "harborId": "string",
    "httpEndpoint": "string",
    "httpsEndpoint": "string",
    "id": 0,
    "isNew": true,
    "liveSystemHost": "string",
    "liveSystemPort": 0,
    "mockServiceTransactions": [
      {
        "priority": 0,
        "txnId": 0
      }
    ],
    "name": "string",
    "noMatchingRequestPreference": "string",
    "noMatchingRequestTxnId": 0,
    "replicas": 0,
    "serviceId": 0,
    "serviceName": "string",
    "shipId": "string",
    "status": "STOPPED",
    "thinkTime": 0,
    "type": "TRANSACTIONAL",
    "updated": "2020-06-17T13:04:42.949Z",
    "updatedBy": "string",
    "updatedDate": "string"
  },
  "skip": 0,
  "total": 0
}