50

I am using Charles (http://www.charlesproxy.com) to debug my HTTP requests and now I run into an issue where I am receiving json response which I need to edit to see how my app behaves.

I was looking at Rewrite option but can't really figure out how to change it. Ideal would be to load whole response from disk.

Any ideas how to accomplish this? Thank you.

user3339562
  • 1,325
  • 4
  • 18
  • 34

4 Answers4

36

The Map Local tool is probably what you're looking for. Access via menu Tools | Map Local.... Note, you may need a corresponding rewrite rule (Tools | Rewrite...) to ensure the mime type of your response served from disk and the type your application is expecting. But recent versions of Charles may set the type automatically.

Michael Luton
  • 1,058
  • 11
  • 29
33

Share how to Enable breakpoints, then change response.

  1. request the link firstly. then enable breakpoint > in the http request right click > choose Breakpoints
    enter image description here
    2. Menu Proxy > Breakpoints Settings > double click the request link enter image description here
    3. change the Scheme GET/POST > Query * enter image description here
    4. modify the request, change the tab Edit Request > you can change the URL, Headers, Cookies, etc > then click the Execute enter image description here
    5. edit the response: choose tab Edit Response > change the response > click the Execute enter image description here
    Enjoy it. You make it.
Zgpeace
  • 3,927
  • 33
  • 31
  • 1
    Is it possible to have charles respond back with a custom JSON evertime until disabled? (As opposed to having breakpoints and updating everytime) – Nevin Madhukar K May 20 '21 at 10:41
  • I think Charges can do it. Just read the response from the json file. But I don't have the experience. Please google. – Zgpeace May 21 '21 at 06:14
  • for my suite it was necessary to remove "Request' mark at "Edit Breakpoint" because in some cases it returns error even if nothing was changed – Nikita Shadkov May 26 '22 at 09:44
26

Charles Proxy change response

As was mentioned Charles Proxy(4.2.8 version) allows you to change response body using different approaches:

  1. Map Local Tool ⌘ command + ⌥ option + L - Use local files to serve remote location
  2. Map Remote Tool ⌘ command + ⌥ option + M - Modify the request location to map one remote location to another
  3. Rewrite Tool ⌘ command + ⌥option + R - Modify requests and responses as they pass through Charles
  4. Breakpoints Tool ⌘ command + ⇧ shift + K - Intercept and edit requests and responses before they are sent and received

Read more here

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
21

Enable breakpoints, then change response. You should press continue/send request to send it before tweak response.

twlkyao
  • 14,302
  • 7
  • 27
  • 44
Ivan Vavilov
  • 1,520
  • 1
  • 15
  • 28