Skip to content

How to Mock an API Response on iPhone Without Changing App Code

Use Request Map in HTTPS Capture to return a fake JSON, image or error response for any URL on iPhone, with a custom status code, headers and delay.

2 min readHTTPS Capture

You might need to see how an app handles an empty list, a 500 error, a slow server, or a feature flag the backend has not shipped yet. Changing the backend or adding debug code to the app takes time. Request Map in HTTPS Capture returns a response you write yourself for any matching URL, directly on the iPhone. The real server is never contacted.

What Request Map does

When a request matches your rule, HTTPS Capture answers it locally with your status code, headers and body. The app cannot tell the difference. It works for any app on the device, including release builds you cannot modify. This is the iPhone equivalent of Charles Map Local.

Create a mock response

  1. Start from the Capture tab and tap Rules → Request Map.
  2. Turn on Enable Request Map and tap + to add a rule.
  3. Pattern: part of the URL, for example api.example.com/v1/profile. Choose Contains for a simple substring or Regex for a regular expression.
  4. Status code: choose from the grouped list (200, 204, 401, 404, 500…) or enter any code from 100 to 599.
  5. Content-Type: choose a preset such as application/json or type your own.
  6. Body: type the response, or tap Insert Template to start from JSON, XML or HTML. Choose File or Choose Photo uses a file or an image as the body, which is handy for mocking images or downloads.
  7. Optional: add custom headers and a delay in milliseconds to imitate a slow network.
  8. Save. The rule applies to the next request right away, and you don’t need to restart capture.

Example: force an empty state

{
  "items": [],
  "total": 0
}

Set the pattern to your list endpoint, status 200 and Content-Type application/json. Open the app and the empty-state screen appears, without deleting any real data.

Example: test error handling

  • Status 500 with an error body checks your retry and error UI.
  • Status 401 checks that the app logs out or refreshes its token correctly.
  • A 200 response with a 3000 ms delay shows whether loading indicators and timeouts behave.

Check that the mock was used

In the request list, the mocked request shows the status and body you defined, and its timing is local. Open it to confirm that the response matches your rule. Only the first enabled rule that matches a URL is used, so put more specific patterns above broader ones.

  • To serve a whole recorded backend instead of single URLs, use Server Replay.
  • To change only part of a real response, use a breakpoint, a rewrite rule or a script.
  • To keep different mock sets apart, create several Profiles and switch between them from the top-left menu.

HTTPS Capture

Capture and decrypt HTTPS traffic on iPhone

App Store

Ready to try it?

HTTPS Capture · Capture and decrypt HTTPS traffic on iPhone

Free on the App Store