0
votes

I am creating/registering "orders/create" hook in shopify but I am getting bellow error

Fatal error: Uncaught exception 'ShopifyApiException' with message 'Unprocessable Entity' in /var/www/wicked_report/shopify.php:70 Stack trace: #0 /var/www/wicked_report/shopifyapp.php(143): ShopifyClient->call('POST', '/admin/webhooks...', Array) #1 {main} thrown in /var/www/wicked_report/shopify.php on line 70

As I am able to create "customers/create" hook.

Here is the code I am using to create hooks

$customerhook = array("webhook"=>array(
                             "topic"=>"customers/create",
                             "address"=>"filepath/customer.php",
                             "format"=>"json"
                            )
                    );
$hook1 = $sc->call('POST', '/admin/webhooks.json', $customerhook);
$orderhook = array("webhook"=>array(
                             "topic"=>"orders/create",
                             "address"=>"filepath/order.php",
                             "format"=>"json"
                            )
                    );
$hook2 = $sc->call('POST', '/admin/webhooks.json', $orderhook);
1
What call causes the error, the first or the second (i.e. which line of code is row 143)? It was some time ago I last used Shopify but could it be that the "address" property needs to be a full URI (with http[s])?kb.
$orderhook = array("webhook"=>array( "topic"=>"orders/create", "address"=>"filepath/order.php", "format"=>"json" ) ); $hook2 = $sc->call('POST', '/admin/webhooks.json', $orderhook); this code send error message... And for address it is full url. I have just changed it with fullpath for security reasons.TBI

1 Answers

1
votes

At the Shopify API authentication process (OAuth), you can add scopes. When you want register orders/create webhook, you need read_orders scope. I think, in your case your scopes are read/customers and write/customers, that is the reason why are you able to create customers/create hook. Try to add read/orders and write/orders.