What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

REST API with Zapier Webhooks Action App

REST API with Zapier Webhooks Action App

Joey_Sturgis
New Member
12 0 0

My goal is to create a Zap that fires every single day, creates and then gets a report of current month to date sales, and then posts this value in a Slack Channel.

 

I already have the following setup:

1. I have created a "Private app" in my Shopify Admin

2. I have already given the amp I intend to use the proper permissions to read and write as necessary

3. I have already used Zapier in a few different ways to actually send and authenticate the request with a positive response back - such as doing "reports" list pull.

 

Where I'm running into issues:

When sending a Post request I am getting the following error:
Failed to create a request in Webhooks by Zapier
Required parameter missing or invalid (HTTP Status Code: 400)
Or I get Bad Request

I've tried Wrapping Request in Array, I've tried flattened and unflattened, I've tried various ways of putting path parameters in the url, in the data, etc. I've tried Custom Request and submit the data RAW literally copied and pasted from a Shopify example.

Nothing works. Can anyone help me understand what needs to be different from the Zapier end of things to make the request go through. I'm usually basing my attempts from CURL examples where it's clear what url to use, what to include in data, and what to include in headers. These type of requests will work when it's an end point like "reports" and you're asking for a list of reports. But trying to Create a report or Get a report all fail.


Replies 6 (6)

Shayne
Shopify Staff (Retired)
254 20 48

It's hard to know what you're talking about here:

>When sending a Post request I am getting the following error:
>Failed to create a request in Webhooks by Zapier
>Required parameter missing or invalid (HTTP Status Code: 400)
>Or I get Bad Request

Where are you sending the post request? Which URL are you using? What's the payload that you're sending? We'll need some more info to help you!

Shayne | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Joey_Sturgis
New Member
12 0 0

Ok after a lot of experimentation, I actually figured out that what I want to do has nothing to do with reports. What I need to do is send a shopifyqlQuery to my shopify app with a Zapier Webhook Custom Request. My call gets rejected with error 400 which tells me the formatting of the data is bad.Untitled-1.jpg

Joey_Sturgis
New Member
12 0 0

I'm finally getting an answer from the server, but no idea how to structure the query. 

Joey_Sturgis_0-1679510775365.png

{
  shopifyqlQuery(FROM orders SHOW sum(net_sales)) {
    # ShopifyqlResponse fields
  }
}
Joey_Sturgis
New Member
12 0 0

Ok, now I'm getting results returned. But I can't figure out how to write a query that just gives me a single point of data (current month to date sales).

Shayne
Shopify Staff (Retired)
254 20 48

From the docs, this query will give you the last year of sales separated by month (which will also show the month to date sales):

FROM orders
VISUALIZE sum(net_sales)
TYPE line
GROUP BY month ALL
SINCE -1y
UNTIL today

Shayne | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Joey_Sturgis
New Member
12 0 0

It would be better if I could structure the query to return a single number as a response. I only need the Month to Date sales, as a number or text. Additional returned information makes it more difficult to then parse the response.