Invalid SQL query

I have the following code with python:

import requests

response = requests.get("https://admin:mypasswd@localhost:9200/_cat/plugins?v",  verify=False)
query = {"query": "select service from fortigate-alias;"}
response ="https://admin:mypasswd@localhost:9200/_plugins/_sql/" , data=query, json=query, headers={"Content-Type": "application/json"}, verify=False)

Then I get the following error:

 "error": {
       "reason": "Invalid SQL query",
       "details": "Failed to parse payload",
       "type": "IllegalArgumentException"
  "status": 400

And I don’t have any error with curl:

curl --insecure -u 'admin:mypasswd' -XPOST https://localhost:9200/_plugins/_sql -d '{"query": "select * from fortigate-alias"}' -k -H 'Content-Type: application/json'

You have to import json module. Then pass data=json.dumps(query)