user2091520
user2091520

Reputation: 21

i have error like bad request while add product in shopify using api

Following errors has occured:

Fatal error: Uncaught exception 'ShopifyApiException' with message 'Bad Request' in D:\xampp\htdocs\cutoutphoto\lib\shopify.php:87 Stack trace: #0 D:\xampp\htdocs\cutoutphoto\lib\shopify.php(203): ShopifyClient->call('POST', '/admin/products...', '{"image":{"posi...') #1 D:\xampp\htdocs\cutoutphoto\requests.php(217): ShopifyClient->update_image('134789371', 'D:\xampp\tmp\ph...', 'tango-featured....') #2 {main} thrown in D:\xampp\htdocs\cutoutphoto\lib\shopify.php on line 87

Upvotes: 0

Views: 772

Answers (1)

Akshay Agarwal
Akshay Agarwal

Reputation: 2039

Wrap the method or the lines where you have ShopifyClient->update_image() in a try...catch block

Eg:

try {

  ShopifyClient->update_image('134789371', '/location/of/the/file', ...); 

} catch(Exception $e){
  //do something with the Exception
  echo $e->getMessage();
}

I think you might be getting the Bad Request error because you are not passing all the parameters to the API or sending those params in the incorrect format. Also, check if you are using the correct authentication credentials for the API.

Also, its helpful for us to answer questions if you do provide some more information like what is your code trying to do, post that block of code here, rather than just the stack trace. But I see this is your first post on Stack Overflow so don't mind :)

Upvotes: 3

Related Questions