Can't seem to send api request using application/graphql

If in Postman I send a request to https://api.monday.com/v2 using the Postman UI Body selection GraphQL, then Postman sends the request using Content-Type: application-json and in the console I see the Request Body

query: "query {
  boards {
    columns {
      id
      title
      type
    }
  }
}"
variables: ""

Which is really confusing, since that request body isn’t valid JSON at all. But the request succeeds.

If I manually set Content-Type: application/graphql and request body

query: "query {
  boards {
    columns {
      id
      title
      type
    }
  }
}"
variables: ""

Then Monday returns

{
    "errors": [
        {
            "message": "'content-type' header must be one of: \"application/json\" or \"application/graphql-response+json\"",
            "extensions": {
                "code": "INVALID_CONTENT_TYPE_HEADER"
            }
        }
    ],
    "account_id": null
}

If I set Content-Type: application/graphql-response+json then Monday returns

{
    "errors": [
        {
            "message": "Invalid GraphQL request",
            "extensions": {
                "details": "failed to deserialize the request body into JSON: expected value at line 1 column 1",
                "code": "INVALID_GRAPHQL_REQUEST"
            }
        }
    ],
    "account_id": 3063938
}

What’s going on?

I can escape the GraphQL payload and send it as application/json and that will work, but this makes the payload unreadable, so I’d rather send it as an application/graphql payload.

Sending an application/graphql payload to the Postman https://graphql.postman-echo.com/graphql api works fine. But a request formatted the same way doesn’t work with the Monday api.

How do I get this to work.

I’m not sure what the problem you are solving is, or are you just trying to understand how Postman and Monday.com API behaves?

When using Postman with the GraphQL selection, the API call is wrapped in JSON and the default content type is application/json. If you click on Console in the bottom left of Postman and when from the Console’s right, click Show Raw Log. You will see that the payload sent is:

{“query”:“query {\r\n boards {\r\n columns {\r\n id\r\n title\r\n type\r\n }\r\n }\r\n}”}

I don’t know why the Content-Type for the API has to be application/json, but that’s how it’s defined in the documentation (Making your first request):

  • Content-Type header must be application/json unless you’re uploading Files

Hope this clarifies the issue.