Shopify GraphQL Returns empty response

kacalica
Tourist
9 0 4

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

Replies 16 (16)

Busfox
Shopify Staff (Retired)
628 49 110

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!

To learn more visit the Shopify Help Center or the Community Blog.

kacalica
Tourist
9 0 4

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 } } 
kacalica
Tourist
9 0 4

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

 

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

 

 

 

kacalica
Tourist
9 0 4

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

kacalica
Tourist
9 0 4

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? 

Busfox
Shopify Staff (Retired)
628 49 110

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, 

To learn more visit the Shopify Help Center or the Community Blog.

kacalica
Tourist
9 0 4

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? 

Busfox
Shopify Staff (Retired)
628 49 110

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

To learn more visit the Shopify Help Center or the Community Blog.

kacalica
Tourist
9 0 4

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:""
Busfox
Shopify Staff (Retired)
628 49 110

Hi @kacalica,

 

I'm not sure where you are making that request to, but the response you get doesn't look right. Can you share the full raw request and response including the endpoint you are hitting? Are you doing this with a cURL request in the console? Or some other way. 

 

Can you try making the same cURL in a console window and see if it works?

To learn more visit the Shopify Help Center or the Community Blog.

ACrego
Excursionist
17 2 7

Maybe it's none of my business, but I'm just passing through looking for answers to a different problem and I noticed this.

 

I have been using postman to test queries for some time now, and I don't know if it makes any difference what is sent via postman vs. what is sent via curl, but the following is what I have been sending, and I tried changing my settings to what the instructions say, and it does not work! I changed my settings back to what they were, and they work! ??? 

 

My settings: 

https://dev-store9.myshopify.com/api/graphql

X-Shopify-Storefront-Access-Token: <storefront-access-token>

Content-Type: application/json

(I have never set the "Accept" header, not even once.)   

 

Also, in my test apps, whether configuring apollo, axios, or whatever, I use those exact same settings and they still work. 

 

Just thought I'd let y'all know. 🙂

Meltin-Bit
Shopify Partner
26 0 10

I am facing the same problem when retrieving a single Order from GraphQL. The 80% of the time the response is ok with status 200 but the body is empty. The Shopify team told be they probably located the problem but they didn't solve it yet. I was enthusiast to switch from rest to graphql but now i am wondering if it was the right choise. Graphql api doesn't seem to be so stable yet.

Meltin Bit
Jetson
Visitor
2 0 0

I am facing the same issue with storefront apis, contacted shopify support, they asked to post the problem here. It was working perfectly fine till yesterday, today suddenly started giving empty response for all the apis. When I try to get the products from the api it returns the response like this. Not sure what I'm doing wrong as it worked before with the same request. Could someone please help. I am using this endpoint: https://(storename).myshopify.com/api/2019-10/graphql.json

 

{
    "data": {
        "products": {
            "edges": []
        }
    }
}
JMB25
New Member
4 0 0

It seems, that this still a problem: Currently I have observed similar behaviours with the customerAccessTokenCreate mutation - sometimes I get a valid json string with status 200 and sometimes I get an empty response with status code 415 (e.g., X-Request-ID: cc8b8897-b2e1-4aec-a78e-1eaa0cf41f7d).

Any updates on this topic?

Thank you, Jan.

tobi_wan
Visitor
1 0 0

I face the same problem. Out of nowhere I get empty responses back for products. It was working fine previously! When I use the graphiql tool everything works fine but when I make the request over axios, insomnia or postman I get empty responses.

What can I do?

Magnolabs
Shopify Partner
1 0 0