Here is an example of a cURL query to the GitHub api v4 that keeps returning an error:
curl -H "Authorization: bearer token" -X POST -d " \
{ \
\"query\": \"query { repositoryOwner(login: \"brianzelip\") { id } }\" \
} \
" https:\/\/api.github.com\/graphql
The error that is returned:
{
"message": "Problems parsing JSON",
"documentation_url": "https://developer.github.com/v3"
}
Why do I keep getting this error?
According to the GH api v4 docs about forming query calls, the above cURL command is valid. Here's what the docs say that backs up my claim that the above cURL command is valid:
curl -H "Authorization: bearer token" -X POST -d " \
{ \
\"query\": \"query { viewer { login }}\" \
} \
" https://api.github.com/graphql
Note: The string value of "query" must escape newline characters or the schema will not parse it correctly. For the POST body, use outer double quotes and escaped inner double quotes.
When I enter the above query into the GitHub GraphQL API Explorer, I get the expected result. The format of the above cURL command looks like this for the GH GraphQL Explorer:
{
repositoryOwner(login: "brianzelip") {
id
}
}