charles-proxy

How to rewrite both GET and POST to the same endpoint with different response bodies?


I need to rewrite with Charles Proxy, with both GET and POST to the same endpoint expecting different response bodies, i.e.:

GET to endpoint should return body1

while

POST to endpoint should return body2

What I see in Charles' rewrite setting is that there is no differentiation between http method so Charles can't know which one I'm referring to.

My (kinda hack-workaround) solution would be to make my application to use endpoint1 for GET and endpoint2 for POST. Charles' setting would be then:

GET to endpoint1 should return body1

POST to endpoint2 should return body2

In this way I'm able to have 2 separate rules. But I think this solution is not elegant.


Solution

  • As you say, Charles does not have any capability to distinguish from different HTTP methods, so the best you can do is probably using different endpoints, which, I agree with you, is not very elegant. Have you tried using some special header? May be you can avoid creating 2 different endpoints...

    Let us know if you can!