What's your biggest current challenge? Have your say in Community Polls along the right column.
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: Getting 404 error while creating webhooks using API.

Getting 404 error while creating webhooks using API.

rashmi2
New Member
10 0 0

HI ,

I am trying to create webhook  using api using following code. (https://github.com/sandeepshetty/shopify_api. 😉

$shopify = shopify_api\client(
  $shop_data->store_name, $shop_data->access_token, $app_settings->api_key, $app_settings->shared_secret
);
//print_r($shopify);
$arguments = array(

'webhooks'=>array
            (
  'topic' => 'cart/updated',
  'address' => 'http://test.com/shopify/shopify_testing/sendPrints.php?key='.$shop_data->store_name,
  'format'=>'xml'
 )
);
try
{

 $webhooks = $shopify('POST', '/admin/webhooks.json', $arguments,$response_headers);
 
 echo 'test';
 echo '<pre>'; print_r($webhooks);echo '</pre>' ;

}
catch (shopify_api\Exception  $e) 

    echo '<pre>'; print_r($e);echo '</pre>' ;
}
catch (shopify_api\CurlException $e)
{            
    echo "doh";
    echo '<pre>'; print_r($e);echo '</pre>' ;
}

 

I am getting following error:


[info:protected] => Array ( [method] => POST [response_headers] => Array ( [http_status_message] => Bad Request [http_status_code] => 400 [server] => nginx [date] => Mon, 21 Apr 2014 12:17:03 GMT [content-type] => application/json; charset=utf-8 [transfer-encoding] => chunked [status] => 400 Bad Request [x-xss-protection] => 1; mode=block [x-content-type-options] => nosniff [x-ua-compatible] => chrome=1 [x-shopid] => 4352121 [x-shardid] => 0 [x-shopify-asset-version] => bac6763d60bfdd59408fe42fb4e6d2ae9b65b101 [x-shopify-shop-api-call-limit] => 1/40 [http_x_shopify_shop_api_call_limit] => 1/40 [x-stats-userid] => 0 [x-stats-apiclientid] => 201113 [x-stats-apipermissionid] => 5887753 [x-request-id] => 60e479dc-5692-49f0-ab87-75d3127f2ae5 ) [response] => Array ( [errors] => Array ( [webhook] => Required parameter missing or invalid ) ) )

 

I have tried a lot to solve this error,  I have also tried 'webhook'=>array  instead of   'webhooks'=>array. but no luck.

can please anyone help me out?

thanks in advance.

         

 

Replies 16 (16)

Evulse
Shopify Partner
411 0 64

I can't see any issue however can you paste the response when you use "webhook" rather than "webhooks" as this isn't correct.

Want an app but can't find what you need? Let us know we custom build apps for Free

Evulse
Shopify Partner
411 0 64

Actually topic is incorrect and should be 'carts/update'

Want an app but can't find what you need? Let us know we custom build apps for Free

rashmi2
New Member
10 0 0

following is the response:

[info:protected] => Array ( [method] => POST [response_headers] => Array ( [http_status_message] => Bad Request [http_status_code] => 400 [server] => nginx [date] => Mon, 21 Apr 2014 12:17:03 GMT [content-type] => application/json; charset=utf-8 [transfer-encoding] => chunked [status] => 400 Bad Request [x-xss-protection] => 1; mode=block [x-content-type-options] => nosniff [x-ua-compatible] => chrome=1 [x-shopid] => 4352121 [x-shardid] => 0 [x-shopify-asset-version] => bac6763d60bfdd59408fe42fb4e6d2ae9b65b101 [x-shopify-shop-api-call-limit] => 1/40 [http_x_shopify_shop_api_call_limit] => 1/40 [x-stats-userid] => 0 [x-stats-apiclientid] => 201113 [x-stats-apipermissionid] => 5887753 [x-request-id] => 60e479dc-5692-49f0-ab87-75d3127f2ae5 ) [response] => Array ( [errors] => Array ( [webhook] => Required parameter missing or invalid ) ) )

Evulse
Shopify Partner
411 0 64

Did you change your topic to the correct "carts/update"?

Want an app but can't find what you need? Let us know we custom build apps for Free

rashmi2
New Member
10 0 0


No, I don't want the solution specific to cart/update I actually wants to create webhook  for  order creation.
do we need to take permission for creating webhooks using API ?
actually I have created one shopify app and creating webhook using API is the part of that app.
I want the orders details when order is created. so I am trying to create webhook.
 

Evulse
Shopify Partner
411 0 64
$arguments = array("webhook" => array(
                            'topic' => $webhook,
                            'address' => $app['shopify']['credentials']['return_url']."webhook/".$webhook,
                            'format' => "json"
                        ));

The above is our arguments code, for order creation $webhook = "orders/create"

Want an app but can't find what you need? Let us know we custom build apps for Free

rashmi2
New Member
10 0 0

what should I placed in 
$app['shopify']  --------->store url ?

['credentials'] ---------> access_token?

['return_url'] --------->   'http://test.com/shopify/shopify_testing/sendPrints.php?key='.$shop_data->store_name  ?

 

Evulse
Shopify Partner
411 0 64
$arguments = array("webhook" => array(
                   'topic' => "orders/create",
                   'address' => 'http://test.com/shopify/shopify_testing/sendPrints.php?key='.$shop_data->store_name,
                   'format' => "json"
                        ));

Is all you would need

Want an app but can't find what you need? Let us know we custom build apps for Free

Evulse
Shopify Partner
411 0 64

I'd also stay away from XML with shopify as they have no guarantees this will work as expected and will be deprecated at some point, if it hasn't already.

Want an app but can't find what you need? Let us know we custom build apps for Free

rashmi2
New Member
10 0 0

how to check whether webhook is created or not ?

now I am not getting any error but not getting whether it is created or not?

Evulse
Shopify Partner
411 0 64

you just need to go to xxxx.myshopify.com/admin/webhooks.json?access_token=xxxxx make sure you do it in a browser that isn't logged in to the admin panel or you won't be able to see it.

Want an app but can't find what you need? Let us know we custom build apps for Free

rashmi2
New Member
10 0 0

getting following error :


{"errors":"SSL required"}
 

Evulse
Shopify Partner
411 0 64

Just put https://xxxx.myshopify.com/admin/webhooks.json?access_token=xxxxx ;

Want an app but can't find what you need? Let us know we custom build apps for Free

rashmi2
New Member
10 0 0

I did the same but getting  same error.

Evulse
Shopify Partner
411 0 64

Always works for me, maybe your behind a proxy or something?

Want an app but can't find what you need? Let us know we custom build apps for Free

rashmi2
New Member
10 0 0

thanks it works  I have  tried by clearing browser's history n cookies.