Blog

One API request with different parameters in one scenario

Check the catalog with page=1 and page=2, an order with a promo code and without. Usually that means copying the request four times in the collection and then editing every copy when the backend changes the address. “Change for this step” in a Microkoi Bench chain changes values only in that step, while the collection keeps a single request.

Why request copies are debt

Marketplace catalog, page 2. Catalog, in-stock items only. Order without a promo code. Each copy is a separate request in the tree with an almost identical name. A month later the backend adds a required header, and it has to go into five places. The fourth one gets forgotten.

A chain step references a request instead of copying it. Step values add a difference to that reference: “the same request, but page=2”. An edit to the request in the collection applies to every step at once. How to build a chain from collection requests is covered in “How to test an API flow end to end: a table booking”.

The requests we start with

Catalog
GET {{baseUrl}}/v1/catalog?page=1&in_stock=true
Body of the “Place order” request
{
  "promo_code": "AUTUMN10",
  "items": [{ "sku": "TEA-0042", "count": 1 }]
}

Put the request into the chain several times

  1. Create a chain and add the “Catalog” request as a step.
  2. Add it again as the second step: “Add step” and the same request from search.
  3. Select the second step. In its properties on the right, find “Change for this step”.
  4. Click “Parameter” and type page — Bench suggests the request’s parameters in the “In the request” list.
  5. Leave the action at “Set” and enter the value 2.

The step on the ribbon gets a “1 change” label next to its name, and the tooltip spells it out: “Parameter page = 2”. The rest of the address goes out exactly as without the change: neighboring parameters and the variables in them aren’t touched.

What you can change

TableExampleAction
“Query parameters”page = 2“Set”
“Query parameters”in_stock“Remove” — the parameter isn’t sent
“Headers”Accept-Language = en“Set”
“Body fields”promo_code“Remove” — an order without a promo code
“Body fields”items[0].count = 3“Set”, type “Number”

A body field has a value type: “String”, “Number”, “True/false”, null or JSON. If you pick a path from the suggestions, the type is filled in from the value in the body. Values can use variables: {{count}}, bench-{{deviceId}}. Typing {{ opens the “Variables” list, which also offers the values earlier steps take, not just the environment. A variable that isn’t set is highlighted in red. If a value is wrong, the properties panel scrolls to the outlined line on its own, so the reason is in full view.

The whole catalog and order scenario

StepRequestStep valuesExpectation
1Catalog—Status code 200
2Catalogpage = 2data.items exists
3Catalogin_stock removedStatus code 200
4Place order—data.discount greater than 0
5Place orderpromo_code removeddata.discount equals 0

The collection still has two requests. After “Run”, the request that was actually sent, with the changes, is in the step’s exchange panel on the “Request” tab: you can see right away what went to the server.

Negative checks the same way

Step values suit the checks nobody usually writes: drop a required header and expect 400, set count = 0 and expect a clear error rather than a 500. Each such check is a step with one change and its own expectation, without another copy of the request.

When body fields can’t be changed

  • Fields change only in a JSON body. For a form, text or XML, the “Body field” button is unavailable: “The request body isn’t JSON, so its fields can’t be changed.”
  • A path past the end of an array, such as items[3] when there are three items, stops the step before sending.
  • A field inside JSON that sits in the body as a string can’t be changed on its own. The whole string can be set instead.
  • A step can have up to 50 changes.

Changes are stored in the chain file and travel with it to git and to the chain monitor. Update Bench for everyone working in a shared workspace: an earlier version that saves such a chain silently erases its step values.

What you get

One request in the collection and as many variants in the scenario as you need to check. When the backend changes the address or adds a header, you edit one place, and every step goes out with the new version.

Build a chain from one request with different values in beta 0.9.6 and write to beta@microkoi.com about the step changes you missed. We read every email.

Microkoi BenchAPI clientCollections, environments, history

Try it on your own project

The beta is free and needs no sign-up. Download it, pick your project folder and start the proxy — your first requests will show up within minutes.

Version 0.9.6 · macOS, Windows and Linux · no sign-up