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?
The simplest way to enable a breakpoint is by selecting the URL and then clicking the breakpoint button in the top toolbar. Enable breakpoints. For more control, open Proxy -> Breakpoint Settings in the menu. Here, we see an overview of all the breakpoints that are set, can edit, remove them or add new ones.
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]*\]
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With