SurrealDB:请求需要遵守某些约束

Hen*_*ryK 5 surrealdb

我只是尝试运行 SurrealDB文档中的第一个查询。

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

这会导致以下错误:

{
  "code": 415,
  "details": "Unsupported media type",
  "description": "The request needs to adhere to certain constraints. Refer to the documentation for supported content types."
}
Run Code Online (Sandbox Code Playgroud)

为什么文档中的查询不起作用?

Tob*_* S. 9

不再需要Content-Type: application/json了。

您需要将其替换为Accept: application/json.

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

Github 上有一个关于此的问题

在 1.0.0-beta.7 中,服务器要求(错误地)设置 Content-Type 标头,但在 1.0.0-beta.8 中更改为 Accept。