NOt able read or process webhook data for products/create

NOt able read or process webhook data for products/create

venkateshm383
Shopify Partner
18 0 3

Hi TEam , I trying read products/create topic using webhook but I am getting below

 

"┃ Failed to process webhook: Error: Could not validate request for topic products/create"

 

 

Later I try to create r/register PRODUCT_CREATE thenI got below error 

 

{"data":{"webhookSubscriptionCreate":{"webhookSubscription":null}},"extensions":{"cost":{"requestedQueryCost":11,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}                      

 

 

Please help what causing this ?  or I am doing wrong , please provide proper if I am missing 

 

 

Thanks 

Venkatsh M

Replies 2 (2)

ReturnPrime
Shopify Partner
488 67 111

Hello,
Can you share more details like if you are using the REST API or some official Shopify library?

Regards,

Mritunjay

ReturnPrime

venkateshm383
Shopify Partner
18 0 3
HI ,Acutully I created custom app using node js as for shopif documentation , in custom app I am trying read products/create data using webhook , I used Admin api to create topic on webhook store side but in the app I am not able to register product_create in webhook ,


Below code I am using for register PRODUCT_CREATE in node app but failing and I tried GraphSQL using command line that alos failing. I pasted error for the below.

const registrationCartUpdate = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: '/webhooks',
topic: 'PRODUCTS_CREATE',
apiVersion: Shopify.Context.API_VERSION,
webhookHandler: async (_topic, shop, body) => {
console.log('received cart update webhook: ');
//Print body
console.log(body);
},
});
if (registrationCartUpdate.success) {
console.log('Successfully registered cart update webhook!');
} else {
console.log('Failed to register PRODUCTS_CREATE webhook', registrationCartUpdate.result);
}




app.post("/webhooks", async (req, res) => {
try {
await Shopify.Webhooks.Registry.process(req,res);
console.log(`Webhook processed, returned status code 200);
} catch (error) {
console.log(`Failed to process webhook: ${error}`);
if (!res.headersSent) {
res.status(500).send(error.message);
}
}
});


ERROR ----:


Failed to register PRODUCTS_CREATE webhook undefined

┃ Failed to process webhook: Error: Could not validate request for topic products/create

┃ Failed to process webhook: Error: Could not validate request for topic products/create


Graph sql ----



curl -X POST \

https://test.myshopify.com/admin/api/2022-04/graphql.json \

-H 'Content-Type: application/json' \

-H 'X-Shopify-Access-Token: access_token‘\

-d '{

"query": "mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) { webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) { webhookSubscription { id topic format endpoint { __typename ... on WebhookHttpEndpoint { callbackUrl } } } } }",

"variables": {

"topic": "PRODUCTS_CREATE",

"webhookSubscription": {

"callbackUrl": "https://87fa-49-205-136-59.ngrok.io/webhooks",

"format": "JSON"

}

}

}'





ERROR :
{"data":{"webhookSubscriptionCreate":{"webhookSubscription":null}},"extensions":{"cost":{"requestedQueryCost":11,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}% venm2@WKMZT900CE0B testapp %