Parse error while creating a report using Shopify Report REST API

AK-at-EP
Visitor
2 0 1

Hello,

 

I am trying to create a report for use in my Custom App.

 

My ShopifyQL query is -- 

"FROM Sales SHOW week, product_id, product_title, pos_location_name, orders, net_quantity GROUP BY week ALL SINCE -30d UNTIL today ORDER BY week"
The ShopifyQL reference clearly says the the order of the syntax must be followed else you will get errors.
 
I get the following error when I POST my request to create the report.
{
    "errors": {
        "shopify_ql": [
            "parse error [0,0]: expected: SHOW, found: FROM"
        ]
    }
}
 I tried putting SHOW as the first clause but then it gives the following error.
{
    "errors": {
        "shopify_ql": [
            "parse error [0,89]: expected: EOF, found: GROUP"
        ]
    }
}
 
Its as if it can only understand SHOW and FROM. No other ShopifyQL clauses.
 
Please help.
 
 
 
Replies 5 (5)

Tristan3dt
Shopify Partner
36 0 16

I'm also having this problem, even when trying queries that are given as examples in the Shopify documentation.  Did you ever manage to get around this, or can anyone else offer any help?

JesseJohnson
Shopify Staff
2 0 0

The REST API supports ShopifyQL V1. The GraphQL supports ShopifyQL V2. The versions are similar but not compatible. In both the ordering of keywords is important. In V1 there's no "GROUP" keyword. The query you want for V1 is probably:

 

SHOW orders, net_quantity
OVER week
BY product_id, product_title, pos_location_name
FROM sales
SINCE -30d
UNTIL today
ORDER BY week

 

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

Tristan3dt
Shopify Partner
36 0 16

Hi, thank you for clarifying this! 

 

In my case, I want to use the products dataset (ultimately I just want to be able to query for order/sales and filter by product collection).  Using a query such as "SHOW sum(gross_sales) FROM products SINCE -30d UNTIL today" is accepted by the REST PUT, but when attempting to view the report in the Shopify Admin it gives the error "

There was an error getting your data. Try reloading the page.".   
 
Any ideas why that might be?
 
JesseJohnson
Shopify Staff
2 0 0

That is odd. Try table `products_v2`.

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

Tristan3dt
Shopify Partner
36 0 16

Hi, same thing, unfortunately! 

Tristan3dt_0-1691062162798.png