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.

Can't register a webhook: Required parameter missing or invalid

BIL_Test_Store_
Shopify Partner
2 0 0

Hi everyone, first time poster here. I've got a lot working with the API with no problems, but I need to register a webhook, and keep getting the "Required parameter missing or invalid" error. I've followed all of the instructions, but maybe I've missed something. 

URL: https://bil-test-store.myshopify.com/admin/webhooks.json

Method: POST

Headers: Content-Type: application/json 
X-Shopify-Access-Token: mytokengoeshere

Body: 

(Body content type application/json)

{"webhooks": 
    {
      "topic": "products/update",
      "address": "https://mysite.co/hooks/shopify/products/update",
      "format": "json"
    }
}

I can validate that the token is good, as if I change anything there I first get the error of invalid token, so it's something with a missing parameter...buy I have NO idea what I am missing. I googled around here and stackoverflow and have found no substantive answers. Any clues on what's missing??

Replies 7 (7)

Alex
Shopify Staff
1561 81 341

It looks like you have `webhook` pluralized at the top level. You're meant to be creating a single webhook, not an array of them. In this case, `webhook` is the missing or invalid required parameter.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

BIL_Test_Store_
Shopify Partner
2 0 0

Ha, how did I miss that? That worked. Thank you. Hangs head in shame, walks away. 

ryanhungate
Tourist
11 0 1

I'm actually getting this as well - but not on all stores, only some... can't seem to create any webhook associations - and also injecting script tags- but let's start with this first...

{"webhook":{"topic":"customers\/create","address":"https:\/\/our_site.com\/hooks\/DYNAMIC_ID\/customers\/created","format":"json"}}

response from shopify:

{"errors":{"webhook":"Required parameter missing or invalid"}}

Is there any way to get some help on this?

 

ryanhungate
Tourist
11 0 1

@shopify - just in case you needed a ping for the above ^^ 

Alex
Shopify Staff
1561 81 341

Hey there.

Can you share an x-request-id I can look at? You'll have received one in the response headers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

ryanhungate
Tourist
11 0 1

Hey Alex, thanks for responding. I was able to figure this out yesterday late... it had to do with me making requests to the actual store domain, not the 'secure_url' and the redirects not working correctly with CURL... so I think the key is to make sure that the secure url is being used at all times, not the domain. 

That would be pretty accurate right?

dnanusevski
Visitor
2 0 2

Hi All

I just want to add, that i had the same problem, and solved it by setting adequate content Content-Type

Here is the code for PHP

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$post_web_hook);


curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "Accept: application/json",
   "Content-Type: application/json"
));

 

//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
 
curl_setopt($ch, CURLOPT_POST, 1);
 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
 
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
 
$page = curl_exec($ch);