Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
Solved

Having difficulty registering a webhook?

edg19
Visitor
3 0 0

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!

Accepted Solution (1)

KarlOffenberger
Shopify Partner
1873 184 898

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.

View solution in original post

Replies 8 (8)

KarlOffenberger
Shopify Partner
1873 184 898

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.

edg19
Visitor
3 0 0

Ah perfect, that did the trick, thanks!

whitecow
New Member
10 0 0

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.


 

KarlOffenberger
Shopify Partner
1873 184 898

@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😉

whitecow
New Member
10 0 0

Great going to try insomnia right now and see if that works.

whitecow
New Member
10 0 0

@KarlOffenberger

 

Much better response.

{
"errors": "[API] This action requires merchant approval for write_products scope."
}

 

Where would I have to give this access at?

 

whitecow
New Member
10 0 0

Fixed that issue by setting this 

Screen Shot 2019-02-10 at 4.08.40 PM.png

 

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.

whitecow
New Member
10 0 0

FIXED! I was calling the wrong endpoint.