Nicolai Lissau
Nicolai Lissau

Reputation: 8332

Working curl query to GraphQL gives 403 in Insomnia and Postman

I followed the first part of this tutorial (until code snippet 4) on GraphQL and serverless.

After deploying the serverless application to AWS I query GraphQL using curl, as shown in snippet 4 of the tutorial and get a response as expected:

$ curl -G 'https://example.execute-api.us-east-1.amazonaws.com/dev/query' --data-urlencode 'query={greeting(firstName: "Jeremy")}'
{"data":{"greeting":"Hello, Jeremy."}}

My problem is that when I attempt to make the same query with either Insomnia or Postman, I get 403 error.

What am I doing wrong? Thank you.

In Insomnia:

Insomnia error

In Postman Postman error

Upvotes: 1

Views: 1846

Answers (2)

Carlos Torres
Carlos Torres

Reputation: 419

To query from Insomnia:

  1. Have an empty body

  2. In the query tab, add a query property with your GraphQL query

  3. In the Header tab, add a x-api-key property with your api key

Upvotes: 0

Nicolai Lissau
Nicolai Lissau

Reputation: 8332

I solved the problem.

While I never got Insomnia to work, I got Postman working.

Turns out that while the configuration in the Postman screenshot I included is correct, I simply forgot that I still had content in the body of the request, which caused the error.

So: Make sure that no query is included in Body if you want to make a GET request

Make sure that no query is included in Body

Upvotes: 1

Related Questions