How to use Charles' rewrite tool only on certain methods?

I think Charles does not have this option, which is really a pitty, because it seems to be easy to implement and it would open the doors to the API world.

I would suggest you to ask Karl (the author and main developer) for this new feature at the contact section of the site.

We have this exact same need to mock API responses. Since the Rewrite tool doesn't support this feature, we have setup Breakpoints on the responses we want to mock, once the breakpoint is hit, we change the response to whatever we want. It works, but is less than ideal.

Unfortunately, Charles doesn't have this feature to filter out which the Request that has certain HTTP Method.

It's not a direct answer, but you can achieve with Scripting tool from Proxyman

scripting to change https status code

function onResponse(context, url, request, response) {

  // Update status Code
  response.statusCode = 500;

  // Done
  return response;

Here is the Snippet Code that you can do with JS Code.

Disclaimer: I'm a creator of Proxyman. Since there are many people who struggle with this problem, hopefully, the Scripting tool can help you.

We were able to work around the issue by assuming that OPTIONS would always return an empty body.

The below Regex values will match for GET (because it has a response body) and not match for OPTIONS (because it doesn't have a response body).




Rewrite Rule