Solved

Post Request to Create Webhook returns 200 with empty array

charjr
Shopify Partner
2 1 1

I make the following request:

POST {{myshopify_url}}/admin/api/2023-07/webhooks.json

With the following body:

{
    "webhook": {
        "topic": "orders/paid",
        "address": "{{address}},
        "format": "json"
    }
}

I get a 200 OK response back with the following:

{
    "webhooks": []
}

I am expecting a 201 Created response with content containing the newly created webhook.

 

I have made a development store with a development app and successfully performed this action, returning a 201 response and creating a webhook.

 

I am now trying to perform the same action on a new store, I've followed the same procedure and ensured I'm using the 2023-07 API version in the app. But I'm getting a 200.

 

I know I have the authentication correct because I can make a GET request to read the list of products from the store. But I cannot seem to create a webhook.

 

Any help would be greatly appreciated.

 

Accepted Solution (1)
charjr
Shopify Partner
2 1 1

This is an accepted solution.

The issue appears to be related to which domain you use.

 

In my case, only the original domain works.

It doesn't matter that we have a different primary domain, nor that the original is set to redirect to it.

When I say original, I am referring to the very first domain that exists when the store is created. In my case it's the domain of randomly generated characters, something like this: 0b93d8.myshopify.com.

 

What I found was that any request that was not sent to my original domain was being treated as a GET request, regardless of what method was used.

 

I verified this by sending a POST request to the original domain instead, it worked exactly as intended, 201, webhook created.

I then sent the exact same POST request to the primary domain, I got a 200 response back with an array containing my newly created webhook (which is exactly what you'd expect from the GET request).

 

Also to clarify, I have now faced this issue on multiple stores, created by different groups of people, during different times. So this is not an isolated issue.

 

Basically, if it's the same issue as I faced: Try the same request to each of the domains, one of them should work.

 

View solution in original post

Replies 3 (3)

areteross
Tourist
3 0 1

Hi, did you ever resolve this? I'm seeing the same issue now. Admin API token is correct (it fails when I change it by a character), and I double-checked all the API params like version, format, topic, address.

 

The odd thing is that if I break the request body to say {"webhoo": {}} instead of "webhook" for example, I still get the 200 response with empty array. Seems like it should fail the request.

charjr
Shopify Partner
2 1 1

This is an accepted solution.

The issue appears to be related to which domain you use.

 

In my case, only the original domain works.

It doesn't matter that we have a different primary domain, nor that the original is set to redirect to it.

When I say original, I am referring to the very first domain that exists when the store is created. In my case it's the domain of randomly generated characters, something like this: 0b93d8.myshopify.com.

 

What I found was that any request that was not sent to my original domain was being treated as a GET request, regardless of what method was used.

 

I verified this by sending a POST request to the original domain instead, it worked exactly as intended, 201, webhook created.

I then sent the exact same POST request to the primary domain, I got a 200 response back with an array containing my newly created webhook (which is exactly what you'd expect from the GET request).

 

Also to clarify, I have now faced this issue on multiple stores, created by different groups of people, during different times. So this is not an isolated issue.

 

Basically, if it's the same issue as I faced: Try the same request to each of the domains, one of them should work.

 

areteross
Tourist
3 0 1

Wow @Char you are an absolute HERO. That was the fix for me too.