Charles: Export only the request body as a seperate JSON file

8.8k views Asked by At

I use charles proxy tool to monitor the requests and response.

Although I can use the export feature of charles proxy tool to extract the complete file as a .chls file. As shown in the below picture,

enter image description here

That .chls file will have the URL, request headers, request body, response header, response body and many other details.

But what I need is only the request body to be saved as a .json file. Is there anyway that I can automate this process?

2

There are 2 answers

2
Kiran Sk On

Go to Charles > Proxy Tab > Enable the Web Interface:

enter image description here

After completing charles session you can launch http://control.charles/session/export-json url to get the JSON format of the request.

To automate this you can use curl command:

Runtime.getRuntime().exec("curl -o file.json http://control.charles/session/export-csv");

0
shaochuancs On

In Charles v4.2.8, this is pretty easy. Just right click the recorded HTTP request, and click "Save Request...".

enter image description here

If HTTP request Content-Type is application/json, its body would be saved. Save the file as xxx.json and it's done.

Note: this feature is possibly added earlier than v4.2.8, but I'm not able to find any announcement in Charles' version history.