Skip to main content

Response payload

In the response payload editor you can either:

  1. Specify the mock response to change the response data.
  2. Forward the original response (only available on paid plans). Upon selecting a modify rule, if you empty the editor, tweak will forward the original HTTP response to the application. This can be useful if you want to modify only HTTP headers or manipulate the original response data with custom JavaScript.

response payload editor

caution

To forward the original HTTP response, the editor must be totally empty (no white spaces).

The response payload editor adapts to the content-type header under the response headers tab. Here are the supported types:

  • JSON - most of the times, developers deal with JSON data. If the content-type is application/json, the JSON language will be enabled in the editor. Furthermore, tweak only serializes/deserializes mock data in JSON when provided the content-type: application/json. Because this is the most common data type, it is the default value when you create a new rule.
  • JavaScript - for cases where the content-type contains application/javascript, the JavaScript language support is enabled for a better experience.
  • For all other use cases, the editor falls back to plain text (e.g. content-type value set to text/plain or others).

Additional features​

  1. To test your application you can send invalid response payloads (e.g. white spaces, malformed JSON etc.). This feature was introduced in tweak v1.1.0.
  2. You can reference variables and use data generators in this editor.


Was this page helpful?