You need /api/v1/query_range not /api/v1/query. See: https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries
If that doesn't help, you may get more clues from print(response.text) -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/3e121d10-4873-44e4-920f-8933b58f409do%40googlegroups.com.

