I have the following code with python:
import requests
response = requests.get("https://admin:mypasswd@localhost:9200/_cat/plugins?v", verify=False)
print(response.text)
query = {"query": "select service from fortigate-alias;"}
response = requests.post("https://admin:mypasswd@localhost:9200/_plugins/_sql/" , data=query, json=query, headers={"Content-Type": "application/json"}, verify=False)
print(response.text)
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'