Query to loki with curl

Hello

I try to get some queries from the grafana API with curl command. Loki is connected as a datasource. To test, I just need to use a simple query. So I try :

curl -k -H "Authorization: Bearer <GRAFANA_TOKEN>" -H "Content-Type: application/json" --request POST --data-urlencode '{"queries":["refId":"A","datasource":{"type":"loki","uid":"gnyGpv7Ik"},"expr":"{pod_name="argocd-application-controller-0"}","queryType":"range","maxLines":1000,"intervalMs":2000,"maxDataPoints":1815],"from":1702396843871,"to":1702400443871}' <GRAFANA_URL>/api/ds/query

The return is “bad request data”, so where are my mistakes ?

Thanks

did you base your query from Dev Tools of your browser?

from docs
In addition, specific properties of each data source should be added in a request (for example queries.stringInput as shown in the request above). To better understand how to form a query for a certain data source, use the Developer Tools in your browser of choice and inspect the HTTP requests being made to /api/ds/query .