How to override API request body in Google Chrome?

Use BrowserStack Requestly to modify API request bodies in Chrome for seamless debugging, testing, and simulation—no code required.

Get Started free
How to override API request body in Google Chrome_
Home Guide How to override API request body in Google Chrome?

How to override API request body in Google Chrome?

When testing APIs, developers often need to simulate different request scenarios, like sending altered payloads, bypassing validation checks, or observing how systems respond to slow network conditions. Traditionally, doing this required changes to the backend or writing custom scripts.

Overview

Overriding an API Request Body refers to the process of intercepting an outgoing HTTP request and replacing or modifying its body (payload) before it reaches the server.

When to perform Override of API Request Body?

  • Testing with Custom Payloads
  • Debugging API Behavior
  • Simulating Errors and Exceptions
  • Mocking Backend Responses Without Changes
  • Testing Multiple Scenarios Efficiently

Use Cases for Overriding Request Body

  • Debugging Backend Responses
  • Simulating Various Test Scenarios
  • Testing API Validations and Edge Cases
  • Mocking External Services or Unavailable Dependencies
  • Repeatable Tests Without Frontend Changes

This guide walks through how to:

  • Override the request body of an API call
  • Simulate network latency using delay rules
  • Streamline your testing workflows with zero backend dependencies

What is API Request Body?

An API Request Body is the data sent by a client (like a browser or mobile app) to a server when making an HTTP request, typically with methods like POST, PUT, or PATCH.

Key Points:

  • It contains structured data (usually in JSON, XML, or form-data) that the server needs to process the request.
  • The request body is not visible in the URL it travels in the payload section of the HTTP request.
  • It is used to send new data or updates to a server-side resource.

Example:

A POST request to create a user might include this body:

json

{

  "name": "Alice",

  "email": "alice@example.com"

}

Common Uses:

  • Submitting form data
  • Sending user credentials
  • Updating database records
  • Triggering business logic (like placing an order)

The request body is essential for APIs that perform data creation or modification, and tools like Requestly allow developers to intercept and modify this body for testing, debugging, and automation.

What is API Request Body Override?

Request body override is the ability to change the contents of an outgoing HTTP request’s body before it reaches the server, without altering the application’s source code or network infrastructure.

This is particularly useful when dealing with POST, PUT, or PATCH API calls that include JSON, form data, or raw payloads.

Instead of modifying the actual frontend application or setting up proxy servers, tools like BrowserStack Requestly allow you to intercept and replace the request body directly in the browser.

When do you need to override a API Request Body?

Here are common situations where this becomes valuable:

  • Testing with Custom Payloads: Send edge-case or malformed inputs to test how APIs respond without triggering the front-end validations.
  • Debugging API Behavior: Override user IDs, authentication tokens, or nested objects to check how the backend behaves under different conditions.
  • Simulating Errors and Exceptions: Send partial, empty, or erroneous data to verify that the system returns appropriate error codes and messages.
  • Mocking Backend Responses Without Changes: Easily swap request body fields (for example, status, amount, userId) to simulate different outcomes without backend involvement.
  • Testing Multiple Scenarios Efficiently: Developers and testers can quickly test different flows using the same frontend by changing just the request body via Requestly rules.

Use Cases for Overriding Request Body

Overriding the request body is a powerful technique that allows developers and testers to simulate complex scenarios without modifying application code or relying on backend services.

Below are common use cases where overriding request bodies with tools like BrowserStack Requestly proves highly effective.

1. Debugging Backend Responses

One of the most common reasons to override a request body is to test how the backend responds to different data inputs. Instead of altering frontend code or writing temporary scripts, you can intercept the request and substitute the body with new values directly.

Example:

Original request body:

json

{

  "userId": "123",

  "amount": 500

}

Overridden body:

json

{

  "userId": null,

  "amount": "five hundred"

}

This allows you to test how the server handles null values or invalid data types.

2. Simulating Various Test Scenarios

In many applications, different user roles or input configurations lead to different behaviors. Overriding request bodies lets you simulate these test scenarios quickly.

Use cases include:

  • Changing user roles (for example, switching between admin and guest)
  • Simulating different user profiles
  • Modifying feature flags or preferences passed in requests

3. Testing API Validations and Edge Cases

Overriding the request body is especially helpful for testing API validation rules. It allows QA engineers to bypass UI constraints and send malformed or edge-case payloads.

Examples include:

  • Sending strings where numbers are expected
  • Removing required fields
  • Using special characters or overly long input
  • Testing deeply nested objects

4. Mocking External Services or Unavailable Dependencies

In staging or development environments, some third-party services may be unavailable or under development. Request body overrides can help simulate interactions with these services.

Example:

If a payment gateway is down, you can override the request body to mimic a successful or failed transaction, allowing frontend and integration tests to proceed.

5. Repeatable Tests Without Frontend Changes

For test automation and regression testing, being able to override requests enables repeatable, consistent results without needing to manipulate the UI or trigger inputs manually.

This is useful for:

  • Running the same API test with multiple input variations
  • Automating backend response simulations in frontend tests
  • Isolating specific request conditions

Requestly Banner

How to Override API Request Body Using BrowserStack Requestly?

Overriding the request body using BrowserStack Requestly is straightforward. Whether you’re simulating different payloads or debugging backend responses, Requestly’s intuitive interface enables you to modify HTTP request bodies in just a few clicks.

Here’s how to do it step-by-step:

Step 1: Install BrowserStack Requestly

  • Go to the Chrome Web Store and search for BrowserStack Requestly
  • Click Add to Chrome and complete the installation

Optional: You can also use the Requestly Desktop App for advanced use cases and mock server capabilities.

Step 2: Launch the Requestly App

  • Click the Requestly icon in your browser toolbar
  • Select “Open App” from the dropdown
  • This opens the Requestly rule management dashboard in a new tab

Step 3: Create a New Rule

  • Click on the “Create New Rule” button
  • Choose “Modify Request Body” from the list of rule types

Step 4: Configure the Rule

4.1 Define the URL Pattern

Specify the URL of the API whose request body you want to override. You can use wildcards (*) or regex if needed.

Example:

sql

https://api.example.com/user/update

4.2 Add the New Request Body

Enter the modified JSON body that you want to send instead of the original.

Example:

json

{

  "userId": "override123",

  "status": "inactive"

}

This will replace the actual request body with the one defined here whenever the rule is active.

4.3 (Optional) Match HTTP Method

You can restrict the override to specific request methods like POST, PUT, or PATCH to ensure the rule is only applied when needed.

4.4 (Optional) Add Conditions

Requestly allows advanced matching conditions like header-based filtering, method matchers, and query parameters.

Step 5: Save and Enable the Rule

  • Click “Save Rule”.
  • Toggle the rule to Active
  • Now, any matching API request will have its body overridden with your custom payload

Step 6: Test in Developer Tools

  • Open the Network tab in Chrome DevTools (right-click > Inspect > Network)
  • Trigger the API call from your application
  • Check the request payload; if set up correctly, the overridden body will be visible

Talk to an Expert

Types of API Request Body Modification

BrowserStack Requestly allows you to modify API request bodies in two powerful modes, Static and Programmatic depending on your use case.

1. Static Mode

In Static mode, you define a fixed JSON payload that will consistently replace the original request body whenever the rule matches.

  • Example Use Case: Testing an API endpoint with a pre-defined user profile or status update.
  • How it works: You simply paste the new payload into the rule editor. Every matching request will then use this payload.
  • Illustration: Overriding a request to https://api.example.com/user/update with:

json

{

  "userId": "test123",

  "status": "inactive"

}

This is best suited for QA testing, mocking user inputs, or simulating static scenarios.

2. Programmatic Mode

In Programmatic mode, you can dynamically generate the request payload using JavaScript. This mode provides access to:

  • The original request body
  • The request URL
  • The HTTP method
  • Query parameters and headers
  • Example Use Case: Sending different payloads based on request method or endpoint (for example, sending different data for POST vs. PUT).
  • Sample Code:

javascript

function modifyBody({ url, method, body }) {

  if (url.includes("/user/update") && method === "POST") {

    return JSON.stringify({ userId: "dynamic001", status: "active" });

  }

  return body; // return original if no changes needed

}

This mode is ideal for complex test scenarios, conditional logic, or dynamic simulations in staging environments.

Both modes help you take full control of API testing without backend changes or complex tooling. Choose the one that fits your test strategy best.

Conclusion

Overriding the request body of an API is a powerful technique for developers and testers who need to simulate real-world scenarios, validate edge cases, or test different payloads without changing the backend code or frontend implementation. With BrowserStack Requestly, you can easily intercept and modify HTTP requests using either static or dynamic payloads—all within your browser.

Whether you’re working on a complex QA workflow or debugging an inconsistent API response, Requestly enables flexible and reliable testing with minimal setup. Its visual interface, Manifest V3 compliance, and JavaScript-based programmatic rules make it a modern solution for request manipulation in Chrome and beyond.

Try BrowserStack Requestly

Tags
Automation Testing Website Testing

Get answers on our Discord Community

Join our Discord community to connect with others! Get your questions answered and stay informed.

Join Discord Community
Discord