Out now! Check out the Poll results: Do you have a Shopify store?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Having difficulty registering a webhook?

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 903

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 903

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 903

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