Reputation: 1495
I'm passing this through Insomnia client with no issues and data returned:
{ "query": "{purchaseOrders{poNumber}}"}
However, when I am trying to push it through curl I'm getting an error. Here is my curl command:
curl -X POST -g -H "Authorization:Bearer token" -H "content-type:application/json" -H "accept:application/json" -d '{"query":"{purchaseOrders{poNumber}}"}' https://api.wayfair.com/v1/graphql
I am getting the following error:
{"errors":[{"message":"Syntax Error GraphQL (1:1) Unexpected <EOF>\n\n1: \n ^\
n","category":"graphql","locations":[{"line":1,"column":1}]}]}
I am not seeing examples that are fashioned like this, and am having success with the API clients, so I'm not sure what the issue could be.
Edit to include the POST request:
POST /v1/graphql HTTP/1.1
Host: api.wayfair.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <token>
Cache-Control: no-cache
Postman-Token: bf83f6be-a560-43b8-8519-6f05a6a60f83
{"query":"{purchaseOrders{poNumber}}"}
Upvotes: 1
Views: 3612
Reputation: 1495
Found the issue:
{"query":"{purchaseOrders{poNumber}}"}
Should be:
{\"query\": \"query { purchaseOrders { poNumber }}\" }
This is now working, with the additional query verb
Upvotes: 3
Reputation: 388
Some GraphQL clients request adicional fields on request as variables
and operationName
.
Example of body:
{"query":"{purchaseOrders{poNumber}}", "variables":null, "operationName":null}"
Upvotes: 0