Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
I've been reading the API documentation to create a webhook, and I'm trying to programmatically create one with this endpoint
POST to this endpoint
https://{username}:{password}@{shop}.myshopify.com/admin/webhooks.json
With this as the body
{
"webhook": {
"topic": "carts/create",
"address": "https://226ef78b.ngrok.io/webhooks",
"format": "json"
}
}
However, for some reason I get back a ton of HTML from the endpoint.
Any ideas where I'm going wrong?
Thank you!
Solved! Go to the solution
This is an accepted solution.
If the tonne of HTML you are receiving is a login form, that's because when doing any POST request on the Admin API, you cannot send cookies along.
This is an accepted solution.
If the tonne of HTML you are receiving is a login form, that's because when doing any POST request on the Admin API, you cannot send cookies along.
Ah perfect, that did the trick, thanks!
I'm having this issue also. I'm not sending any cookies.
I'm using postman to post and getting this type of response back
<html>
<body>
<noscript>
<a href="https://accounts.shopify.com/oauth/authorize?
@KarlOffenberger wrote:If the tonne of HTML you are receiving is a login form, that's because when doing any POST request on the Admin API, you cannot send cookies along.
@whitecow I don't know much about Postman since I don't use it, but here is a link that should help i.e. even if you aren't adding any cookies, Postman will.
Better solution - use Insomnia and never look back (here's a Shopify tutorial how to get started with Insomnia) 😉
Great going to try insomnia right now and see if that works.
Much better response.
{
"errors": "[API] This action requires merchant approval for write_products scope."
}
Where would I have to give this access at?
Fixed that issue by setting this
I'm now getting this though
{
"errors": {
"product": "Required parameter missing or invalid"
}
}
My post looks like this
{
"webhook": {
"topic": "checkouts/create",
"address": "https://myendpoint",
"format": "json"
}
}
FYI my endpoint is just a dummy right now and does nothing other than accept json.
FIXED! I was calling the wrong endpoint.