{question}
How to resolve "Received HTTP/0.9 when not allowed" when using Data API?
{question}
{answer}
Data API is a JSON-based SQL API developed by SingleStore that can be used to execute SQL statements against the database over an HTTP connection. It can be used to integrate SingleStore with various applications.
When using curl to implement Data API and execute the desired queries, an error of the following type might be encountered:
curl -H "Content-Type: application/json" --data '{"sql": "select 1+1"}' --user 'username:password' http://servername:port/api/v2/query/rows
curl: (1) Received HTTP/0.9 when not allowed
- This error indicates that the curl command is sending an HTTP request to the SingleStore Server, but is being rejected as the server has not been configured for accepting these requests.
- If curl is used to query the server where Data API has not yet been enabled, this results in the above issue hence, the database server is unable to forward the HTTP requests and rejects them. WebSocket Proxy information needs to be updated in the SingleStore engine for the database to forward these requests.
- In order to resolve this issue, SingleStore needs to be configured using the steps mentioned in the following documentation -> Enable the Data API
- Once these steps have been implemented, Data API connectivity can be tested by issuing the below command:
curl http://<hostname>:8080/ping
- The above HTTP request will return a response
pong
. This will ensure that Data API has been set up and is working correctly.
Other related references:
HTTP API on SingleStore Cloud.
{answer}