Skip to main content

Request payload

The request payload has different UIs depending on the rule type.

Mock rules​

The request payload acts as a filter to intercept the intended requests. This data is not sent out to the server.

For example, you can combine URL and request payload to target a specific POST request and configure more granular rules. This is useful when all APIs are behind the same endpoint and the request payload is the only variant (e.g. GraphQL).

default behavior

When creating a new rule the request payload is empty by default.

request payload with a mock rule

caution

When you leave the request payload empty, all requests are intercepted, regardless of the request body. This is valid for mock and modify rules.

Modify rules​

info

Modify rules are only available on paid plans. Check our plans here.

With modify rules you can also specify a request payload to replace the original. tweak will replace this data on the fly, before the request leaves the browser.

request payload with a modify rule

In the above image, the request payload { "id": 200 } is going to be replaced by { "id": 202 }. If you open the devtools you can see the modified request payload.

tip

Do you need more granularity on replacing the request payload? Use a "Request hook" instead.

Form request bodies​

A request whose Content-Type is application/x-www-form-urlencoded (a classic HTML form post, many OAuth token endpoints) carries its body as name=Jon+Snow&house=Stark. Editing that as text is error-prone, so tweak edits it as a key/value table instead: one row per field, already decoded.

a mock rule matching a form post by its fields

The switch is the request's Content-Type. A strip above the request payload tab shows it (JSON, Form URL-encoded, Plain text or None): pick Form URL-encoded and the editor becomes the table. On a modify rule that strip is the very same Content-Type row you see in the request headers tab, and it is sent with the request. On a mock rule it only describes the request being answered.

When a form rule matches, the order of the fields does not matter: house=Stark&name=Jon+Snow matches the table above. Partial matching works field by field too. Leave the table empty to match any payload. Variables work in the cells, and a request picked from request capture that was a form post arrives already as a table.

Additional features​

  1. You can reference variables and use data generators in this editor.
  2. By default tweak looks for a strict match in the request payload. You can relax the matching criteria. Read more here.


Was this page helpful?

Need something else? Request a feature