1

The following GraphQL query runs perfectly fine in Github GraphQL Explorer:

$ cat GraphQL_query.graphql
query {
  __schema {
    types {
      name
      kind
      description
      fields {
        name
      }
    }
  }
}

however, when I send it via curl:

curl -H "Authorization: bearer token" -X POST -d "`cat GraphQL_query.graphql`" https://api.github.com/graphql

I'll get:

{
  "message": "Problems parsing JSON",
  "documentation_url": "https://developer.github.com/v4"
}

What's wrong? How can I make it works? Thx.

4

1 回答 1

3

curl查询的语法如下所示:

$ curl -H "Authorization: Bearer $GITHUB_PRODUCTION_TOKEN" https://api.github.com/graphql -X POST -d '{"query":"query { __schema { types { name kind description fields { name } } } }","variables":"{}"}'
于 2018-03-30T18:20:23.247 回答