Unable to regsiter discount related webhooks dynamically

Unable to regsiter discount related webhooks dynamically

AjeetSingh1
Shopify Partner
9 0 0

I'm integrating Shopify into my App. In that, I'm registering webhooks dynamically. I can register all other webhooks for customers, orders, and products successfully. But I'm registering a webhooks for discounts as "discounts/create, discounts/update, discounts/delete", it's throwing an error as "API Exception (404): {'errors': 'Could not find the webhook topic discounts/create'". My app is already authenticated with scopes "read_discounts, write_discounts". I'm using this code to register a webhook,


POST "/admin/api/2024-01/webhooks.json" 
 

{
"webhook": {
"topic": "discounts/create",
"address": "my host",
"format": "json"
}
}
 

Reply 1 (1)
AjeetSingh1
Shopify Partner
9 0 0

My store is, "cascade-test-store-1.myshopify.com", And I'm using this code to register a webhook,

const webhookData = {
webhook: {
topic: "discounts/create",
address: `my host`,
format: 'json',
},
};
const response = await axios({
method: 'post',
url: `https://${storeDomain}/admin/api/2024-01/webhooks.json`,
data: webhookData,
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': accessToken,
},
});