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} ],
"httpRunnerEnabled" : true, "messagingRunnerEnabled": false }'
Create a virtual service request attributes
Attributes
-
descriptionstringThe description of the new virtual service.
-
endpointPreferencestringChoose HTTP or HTTPS.
-
httpRunnerEnabledBooleanThe HTTP runner is the default runner for virtual services. Either "httpRunnerEnabled" or "messagingRunnerEnabled" must be set to true.
-
messagingRunnerEnabledBooleanThe messaging runner supports MQ messaging in virtual services. Either "httpRunnerEnabled" or "messagingRunnerEnabled" must be set to true. By default, this is set to false.
-
httpRunnerOverrideKeystoreBooleanEnables the keystore override for the HTTP runner. This setting will apply the keystore certificates attached in the SSL settings to the runner keystore. Default: true. If a messaging runner needs to use SSL authentication, but the HTTP Runner does not, then set this to false.
-
httpRunnerOverrideTruststoreBooleanEnables the truststore override for the HTTP runner. This setting will apply the keystore certificates attached in the SSL settings to the runner truststore. Default: true. If a messaging runner needs to use SSL authentication, but the HTTP Runner does not, then set this to false.
-
typestringSet the type to "TRANSACTIONAL" for transactional virtual services. The legacy value "SV" for DevTest MAR-based Mock Services (EOL) is deprecated.
-
liveSystemHoststringThe host of the live system.
-
liveSystemPortintegerThe port of the live system.
-
namestringThe name of the virtual service.
-
noMatchingRequestPreferencestringDetermines what to do if there are no matching requests. Choose either
return404to return "no match found", or choosebypassliveto redirect to the configured live system. -
noMatchingRequestTxnIdintegerIf there are no matching requests, this is the transaction ID that did not match.
-
serviceIdintegerThe identifier of an existing Service container that contains this virtual service.
-
thinkTimeintegerThink time is a synthetic delay inserted between test steps to ensure the test script moves at a human pace.
-
mockServiceTransactionsarrayThe 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 virtual service. 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. -
shipIdstringThis 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').
-
harborIdstringThis identifier was used in MAR-based Mock Services (EOL) only. The identifier of the private on-premise location (also know as 'harbor'), a logical container on the BlazeMeter end that contains one or more agents (also know as 'ships') on your end.
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
}