When I send a request to a specific website API I get this as response
{
"Tickets": [
{
"ticketAvailable": true,
...
How would I intercept and change ticketAvailable
to false
instead of true
using mitmproxy?
from mitmproxy import ctx
from mitmproxy import http
import json
def response(flow: http.HTTPFlow) -> None:
if flow.request.pretty_url == "https://example.com/api/v1/something":
data = json.loads(flow.response.get_text())
data["data"]["Tickets"]["ticketAvailable"] = false
flow.response.text = json.dumps(data)
I have tried this, but it doesn't seem to work.
EDIT: Have not managed to fix it yet
from mitmproxy import ctx
from mitmproxy import http
import json
def response(flow: http.HTTPFlow) -> None:
if flow.request.pretty_url == "https://example.com/api/v1/something":
data = json.loads(flow.response.get_text())
data["Tickets"][0]["ticketAvailable"] = "false"
flow.response.text = json.dumps(data)