Graphql post body "Must provide query string."

Post request needs to manage headers info.

  1. Using Http client: Content-Type application/json

  2. Using Postman client: Content-Type application/graphql

but request body looks like string

{"query":"mutation{update(id:1,x1:\"zazaz\",x2:\"zazaz\"......){id x1 x2}}"}

If you are using graphql and want to test it using postman or any other Rest client do this.

In postman, select POST method and enter your URL and set Content-Type as application/graphql then pass your query in the body.

Example:

http://localhost:8080/graphql
Mehtod: POST
Content-Type: application/graphql
Body: 
  query{
    FindAllGames{
    _id
    title
    company
    price
    year
    url
   }
 }

Thats it you will get the response.

enter image description here


Using Postman Version 7.2.2 I had a similar issue. This version of Postman supports Graphql out of the box. Changing the Content-type to application/json fixed it for me.

Image showing the Content-type in Postman


for me worked like as following:

In the body

Body postman

In the Headers

Header postman

Don't forget mark GraphQl [x] on Body settings

enter image description here

And how was quoted before changes the verb to POST.