Shopify GraphQL Returns empty response

New Member
7 0 0

I am trying to just get some data back from the Storefront API using GraphQL. For some reason, I get an empty response. I am using Postman but I will be posting the generated cURL code it gives. 

 

 

curl -X POST \
  http://test-store-calica.myshopfiy.com/api/2019-07/graphql \
  -H 'Accept: */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 105' \
  -H 'Content-Type: application/graphql' \
  -H 'Cookie: __tad=1567709864.5364039' \
  -H 'Host: test-store-calica.myshopfiy.com' \
  -H 'Postman-Token: 43bb893e-3fdf-484f-9487-4401dec68b00,e33699c1-4619-4a49-ac51-2b7ff3517bb3' \
  -H 'User-Agent: PostmanRuntime/7.15.2' \
  -H 'X-Shopify-Storefront-Access-Token: 26bc677d47d31bd703a384c5731fde79' \
  -H 'cache-control: no-cache'
-d '{
products {
edges {
node {
id
title
}
}
}
}'

 

 

I have tried simple queries like: 

{
  shop {
    name
  }
}

Still empty response

0 Likes
Community Manager
Community Manager
619 46 79

Hi @kacalica,

 

A few things are jumping out at me that you could try changing. Namely, can you try changing the Content-Type to application/json and removing cookies from your request? If you continue to have trouble, I can take a look in our logs for the request if you can share the request id found in the response headers for one of the calls not working.

 

Thanks!

0 Likes
New Member
7 0 0

I updated the request and took out the cookie header and changed it to application/json

 

I still get an empty response. 

 

curl -X POST http://test-store-calica.myshopfiy.com/api/2019-07/graphql 
-H 'Accept: */*' 
-H 'Accept-Encoding: gzip, deflate' 
-H 'Cache-Control: no-cache' 
-H 'Connection: keep-alive' 
-H 'Content-Length: 94' 
-H 'Content-Type: application/json' 
-H 'Host: test-store-calica.myshopfiy.com' 
-H 'X-Shopify-Storefront-Access-Token: 26bc677d47d31bd703a384c5731fde79' 
-H 'cache-control: no-cache' -d "{ shop { name } } 
0 Likes
New Member
7 0 0

Here is the response object I receive when I look in my Postman console:

 

id:"516f436e-421c-46b5-9107-cdd9450698ae"

 

 

 

0 Likes
New Member
7 0 0

Just tried the curl request GIVEN to me in the docs: 

 

curl -X POST \
"https://test-store-calica.myshopify.com/api/2019-07/graphql" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Storefront-Access-Token: <storefront-access-token>" \
-d '
{
  collections(first: 5) {
    edges {
      node {
        id
        handle
      }
    }
    pageInfo {
      hasNextPage
    }
  }
}
'

The empty response is returned, so not a Postman issue or my request being crafted. Something is weird about my development store? Is there any setup I have to do to use GraphQL, @Busfox

0 Likes
New Member
7 0 0

I fixed it! 

 

I actually noticed I wasn't getting an empty response but my response code was `415 Unsupported Media Type` 

 

The documentations asked for `Content-Type` to be `application/graphql` but this doesn't seem to work. I don't know if just in Postman or also in cURL. 

 

But I changed two things: 

  1. `Content-Type` set to `application/json`
  2. Changed the endpoint to be `/2019-07/graphql` to `/2019-07/graphql.json` 

The documentation here: https://help.shopify.com/en/api/storefront-api/getting-started

 

Doesn't mention this and actually states to do it the way I originally tried it. But I don't know if the docs are wrong or are for a specific version? I tried make two development stores and only the changes I made above can access those endpoints. 

 

Any word on this @Busfox  ? How reliable is the documentation? Is this due to specific versioning? 

0 Likes
Community Manager
Community Manager
619 46 79

Hi again @kacalica,

 

I did some digging and found that this doc page does not reflect a fairly recent change behind the scenes that has caused the cURL examples to be invalid. We'll be shipping a fix to these examples as soon as possible.

 

If you add -H "Accept: application/json" to your cURL request, you should be able to use the example how it is otherwise stated in the docs.

 

Cheers, 

0 Likes
New Member
7 0 0

I spoke to soon. Now it's a blank response again with a 200 response code. 

 

I added the Accept Header and did not change anything. 

Is there a link to new documentation? 

0 Likes
Community Manager
Community Manager
619 46 79

Hi @kacalica,

 

The updated documentation can be found here.

 

I'm not having an issue with the examples you shared previously. I can take a look if you share a request-id value.

 

Cheers

0 Likes
Highlighted
New Member
7 0 0

Strangely I don't get a request-id back I am just getting back an empty response with 200 status code. 

Response Headers:
Date:"Mon, 16 Sep 2019 21:47:44 GMT"
Server:"Apache/2.4.25 (Debian)"
Content-Length:"0"
Connection:"close"
Content-Type:"text/html; charset=UTF-8"
Response Body:
 

This was my request: 

 

Request Headers:
X-Shopify-Storefront-Access-Token:"XXXXXXX"
Content-Type:"application/graphql"
Accept:"application/json"
Host:"test-store-calica.myshopfiy.com"
Accept-Encoding:"gzip, deflate"
Content-Length:47
Connection:"keep-alive"
Request Body:
query:"query { shop { name } }"
variables:""
0 Likes