charles-proxy

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


I'm using Charles' Rewrite Tool to change 200 responses to 400 in order to test failing API calls. However, the rewrite is triggering on the Options request. I'd like to only have it trigger on the Get or Post requests and allow the Options requests through. Is this possible using Charles?

Rewrite Screen


Solution

  • 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).

    \{[\S\s]*\}

    or

    \[[\S\s]*\]

    Rewrite Rule