Is it possible to rewrite a status code with Charles Proxy?

Using Charles 3.8+, you can rewrite the status code.

In the rewrite tool, select "Type: response status". In the match fields and replace fields, be aware that Charles expects the incoming and rewritten statuses to match the format "\d{3} .*". This means that your rewritten status must have a message portion in addition to the numeric status code.

For example:

Match value: 201 .*

Replace value: 502 Bad Gateway

Omitting the message from the replace value will result in no rewrite of the status line. You can see Charles' rewrite tool output messages in the Notes section of each call's summary.


An Update: Version 3.8 of Charles Proxy was just released, with the ability to rewrite the status. From the release notes:

  • Rewrite tool: allow rewriting of response status

This version's rewrite UI adds a new "Response Status" rule type:

enter image description here


1- Select Tools > Rewrite or OPTION + CMD + R

Rewrite selection


2- Select Enable Rewrite and then select Add

Enable Rewrite selection


3- Fill the fields with your details

Details


4- Add type and action

Type and Action


5- Select type of action - Response Status for our case -, write value to be changed -500-, write value for replace -200-

Configure Type and Action


Final Step:

6- You are ready to manipulate status code of your response with Charles

Finally

Official site of Charles Web Debugging Proxy