Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
I want to create a webhook that sends metafield data. It seems I must do this via the API and not the Admin console so that I can specify metafield_namespaces.
I am trying to create a webhook using a Private App api key. However, it seems I don't have access to events/webhooks with this api key. How do I get a key with the required access without building a Public App?
I am trying to POST the following to https://MYSHOP.myshopify.com/admin/api/2019-04/webhooks.json
{ "webhook": { "address":"https://WEBSERVICE_URL", "topic":"customers/create", "format": "json", "metafield_namespaces": [ "MYNAMESPACE" ] } }Thank you
Hi @kingsleyg
There should be no specific scope needed to create webhooks to my knowlage, as long as your app has access to the read_customers, write_customers scopes you should be fine.
What error is returned from Shopifys API when you try and POST?
Best,
Jesper
Perhaps? What is strange is I get a 200 response but with html trying to prompt a login
<html> <body> <noscript> <a href="https://app.shopify.com/services/login/identity?CALLBACK</a> </noscript> <script type="text/javascript"> window.location = "https:\/\/app.shopify.com\/services\/login\/identity?CALLBACK"; </script> </body> </html>
Note that I receive a valid JSON response to GET - reflecting that no webhooks have been deployed via the Private App api
{ "webhooks": [] }
And all other api calls are working fine in the same environment
Okay, you will need the private app to create the Webhooks, because webhooks are "private" to the API key.
Normally the GET request should return all registrated webhooks for the API key, so looks like there was an error while creating the webhook in the first place?
When you do a POST request to create a new webhook, you should either get an error or an 201 created response code 🙂
Yes, you can create webhooks using a private app as well, I've just checked on my dev shop 🙂
Does the app have read and write access to customers of the shop? Sounds like its not authorized.
I've used postman to send a POST request to https://{api_key}:{api_secret}@{permanent_domain}.myshopify.com/admin/api/2019-04/webhooks.json as shown below and that works fine.
{ "webhook": { "topic": "customers/create", "address": "https://testdomain.com/", "format": "json" } }
Response:
201 Created
{ "webhook": { "id": 598423830628, "address": "https://testdomain.com/", "topic": "customers/create", "created_at": "2019-05-09T01:17:37-12:00", "updated_at": "2019-05-09T01:17:37-12:00", "format": "json", "fields": [], "metafield_namespaces": [], "api_version": "2019-04" } }
Thanks for trying in your own environment. I tried the exact same as you and still get the error.
I don't see any available options to enable in the Private App setting area.
I can read and write to Customers using the same api key.
I guess I'll have to open a ticket.
Hey @kingsleyg , did you manage to solve the issue? Struggling with the same right now.
Update for those who stumble upon this thread like I did:
I was using Postman for making requests and what helped me was to delete all cookies in the app -> then the '200 OK login screen' error disappeared.