The correct content type for GraphQL requests is application/graphql-response+json or application/json. Action API users may be used to sending multipart/form-data data requests which currently results in a confusing error.
Example curl request:
curl --request POST \
--url 'http://default.mediawiki.local.wmftest.net:8080/w/api.php?action=wbgraphql&format=json' \
--header 'content-type: multipart/form-data' \
--form 'query={ __typename }'This currently results in the following response:
{
"warnings": {
"main": {
"*": "Unrecognized parameter: query."
}
},
"errors": [
{
"message": "The 'query' field is required and must not be empty"
}
]
}Instead, the error response should be as follows, without the warning message:
{
"errors": {
"message": ["Requests must be sent as 'application/json' or 'application/graphql-response+json' "]
}
}