Hey everyone,
I’ve created a webhook subscription through the Shopify Admin API using the following code:
const webhookData: Webhook_POST = {
webhook: {
address: `https://xyz.com/v1/webhook/checkouts-delete?shop=${shopId}`,
format: 'json',
topic: topic,
},
};
await Axios.post(
`https://abc-shop.myshopify.com/admin/api/2023-07/webhooks.json`,
webhookData,
{
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': accessToken,
},
}
);
Initially, I mistakenly provided the webhook URL with double https
(like https://https//xyz.com
), but I corrected it to a single https
soon after.
However, the issue is :
- Sometimes Shopify still attempts to send requests to the incorrect double
https
URL (https://https//xyz.com/v1/webhook/checkouts-delete?shop=xxxxx
), which results in a 503 Service Unavailable
error.
- Other times, it hits the correct endpoint (
https://xyz.com/...
) and works as expected with a 200 OK
response.
I can’t figure out why Shopify is intermittently using the old, incorrect URL. Has anyone encountered this issue before or have insights into why this might be happening?
Hi @Aakanksha_Gupta,
If Shopify is unable to successfully send a webhook message it will retry sending that same webhook up to 8 times over the following 24 hours. My guess is the webhooks you’re seeing to the old URL are Shopify retrying those requests that were initiated when the old URL was configured.
For any new webhooks that are triggered, they should just go to the new URL that you configured. Does that match up with what you’re seeing?
Best,
Daniel
Hey @Daniel_Ablestar, whenever new webhooks are triggered, sometimes they are sent to the old URL and other times to the new URL. I don’t understand why this is happening.
Hi @Aakanksha_Gupta,
Initially, I mistakenly provided the webhook URL with double https
(like https://https//xyz.com
), but I corrected it to a single https
soon after.
Did you achieve this with a PUT
request Webhook - REST
I’m asking because it sounds like you may have two subscriptions set up.
Run a GET request to check how many subscriptions are in place:
https://shopify.dev/docs/api/admin-rest/2024-10/resources/webhook#get-webhooks
@leggetter , i have not used put request ,
i tried to run a GET request. i have provided X-Shopify-Access-Token in header ,
it is giving bad request for GET. but when i run post request , i am recieving the response.
Ok, so it sounds like you have two webhook subscriptions. One with the double https
and the other correctly set up on.
Does your GET
code look something like the following?
const webhookSubscriptions = await Axios.get(
`https://abc-shop.myshopify.com/admin/api/2023-07/webhooks.json`,
{
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': accessToken,
},
}
);
console.log(webhookSubscriptions);
1 Like
Hey, if i am sending like this then i am able to get response.
can you please tell me why i am getting bad request when i am sending it from postman.
Have you worked out if you have two subscriptions in place? Is that why you were getting webhooks sent to the older double https endpoint?
The cURL for the GET
request generated from Postman is:
curl --location 'https://abc-shop.myshopify.com/admin/api/2024-10/webhooks.json?=' \
--header 'X-Shopify-Access-Token: {accessToken}'
1 Like
Thankyou so much . It worked, Yes, there were two webhook subscription.
1 Like