4

I just tried to run the first query from the SurrealDB documentation.

DATA="INFO FOR DB;"
curl --request POST \
    --header "Content-Type: application/json" \
    --user "root:root" \
    --data "${DATA}" \
    http://localhost:8000/sql

This leads to the following error:

{
  "code": 415,
  "details": "Unsupported media type",
  "description": "The request needs to adhere to certain constraints. Refer to the documentation for supported content types."
}

Why doesn't the query in the docs work?

HenryK
  • 41
  • 2

1 Answers1

7

The Content-Type: application/json is not needed anymore.

You need to replace it with Accept: application/json.

DATA="INFO FOR DB;"
curl --request POST \
    --header "Accept: application/json" \
    --user "root:root" \
    --data "${DATA}" \
    http://localhost:8000/sql

There was an issue on Github about this.

In 1.0.0-beta.7 the server required (incorrectly) the Content-Type header to be set, but this was changed to Accept in 1.0.0-beta.8.

Tobias S.
  • 21,159
  • 4
  • 27
  • 45