Jump to content

Edit History

absens00

absens00

Hi! I'm trying to add/upload product images via Prestashop API, but I'm getting server error 500. What can be wrong with the code? Or maybe there's something wrong with the server configuration?

Prestashop version: 1.7.6.4

PHP script:

error_reporting(-1);
ini_set('display_errors', 'On');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://[email protected]//api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' =>'@http://my-shop.com/img/my-shop-logo-1584646645.jpg;type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);

print_r($curlinfo);

This results in [http_code] => 500. There's no error or anything. I have access to the hosting provider's server error log, but there's nothing in there...
I've enabled debug mode in the back office, but it doesn't seem to affect the API. Is there any other way to debug it?

The script is based on the Prestashop docs: https://devdocs.prestashop.com/1.7/development/webservice/tutorials/change_product_image/

absens00

absens00

Hi! I'm trying to add/upload product images via Prestashop API, but I'm getting server error 500. What can be wrong with the code? Or maybe there's something wrong with the server configuration?

Prestashop version: 1.7.6.4

PHP script:

error_reporting(-1);
ini_set('display_errors', 'On');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://[email protected]//api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' =>'@http://my-shop.com/img/my-shop-logo-1584646645.jpg;type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);

print_r($curlinfo);

This results in [http_code] => 500. There's no error or anything. I have access to the hosting provider's server error log, but there's nothing in there...
I've enabled debug mode in the back office, but it doesn't seem to affect the API. Is there any other way to debug it?

The script is based on the Prestashop docs: https://devdocs.prestashop.com/1.7/development/webservice/tutorials/change_product_image/

absens00

absens00

Hi! I'm trying to add/upload product images via Prestashop API, but I'm getting server error 500. What can be wrong with the code? Or maybe there's something wrong with the server configuration?

Prestashop version: 1.7.6.4

PHP script:

error_reporting(-1);
ini_set('display_errors', 'On');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://[email protected]//api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' =>'@http://my-shop.com/img/my-shop-logo-1584646645.jpg;type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);

print_r($curlinfo);

This results in [http_code] => 500. There's no error or anything. I have access to the hosting provider's server error log, but there's nothing in there...
I've enabled debug mode in the back office, but it doesn't seem to affect the API. Is there any other way to debug it?

The script is based on the Prestashop docs: https://devdocs.prestashop.com/1.7/development/webservice/tutorials/change_product_image/

// Edit:

I've also tried using CurlFile, but in this case I'm not getting any HTTP code at all...

error_reporting(-1);
ini_set('display_errors', 'On');

$image_path = 'http://my-shop.com/img/my-shop-logo-1584646645.jpg';
$image_mime = 'image/jpg';

$args['image'] = new CurlFile($image_path, $image_mime);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_URL, 'http://my-shop.com/api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);

print_r($curlinfo);

What I get is:

Array
(
    [url] => http://my-shop.com/api/images/products/24/
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1

I can't figure out what's wrong

absens00

absens00

Hi! I'm trying to add/upload product images via Prestashop API, but I'm getting server error 500. What can be wrong with the code? Or maybe there's something wrong with the server configuration?

Prestashop version: 1.7.6.4

PHP script:

error_reporting(-1);
ini_set('display_errors', 'On');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://[email protected]//api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' =>'@http://my-shop.com/img/my-shop-logo-1584646645.jpg;type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);

print_r($curlinfo);

This results in [http_code] => 500. There's no error or anything. I have access to the hosting provider's server error log, but there's nothing in there...
I've enabled debug mode in the back office, but it doesn't seem to affect the API. Is there any other way to debug it?

The script is based on the Prestashop docs: https://devdocs.prestashop.com/1.7/development/webservice/tutorials/change_product_image/

I'd be grateful for any advice.

absens00

absens00

Hi! I'm trying to add/upload product images via Prestashop API, but I'm getting server error 500. What can be wrong with the code? Or maybe there's something wrong with the server configuration?

PHP script:

error_reporting(-1);
ini_set('display_errors', 'On');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://[email protected]//api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' =>'@http://my-shop.com/img/my-shop-logo-1584646645.jpg;type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);

print_r($curlinfo);

This results in [http_code] => 500. There's no error or anything. I have access to the hosting provider's server error log, but there's nothing in there...
I've enabled debug mode in the back office, but it doesn't seem to affect the API. Is there any other way to debug it?

The script is based on the Prestashop docs: https://devdocs.prestashop.com/1.7/development/webservice/tutorials/change_product_image/

I'd be grateful for any advice.

absens00

absens00

Hi! I'm trying to add/upload product images via Prestashop API, but I'm getting server error 500. What can be wrong with the code? Or maybe there's something wrong with the server configuration?

PHP script:

error_reporting(-1);
ini_set('display_errors', 'On');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://[email protected]//api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' =>'@http://my-shop.com/img/my-shop-logo-1584646645.jpg;type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);

print_r($curlinfo);

This results in [http_code] => 500. There's no error or anything. I have access to the hosting provider's server error log, but there's nothing in there...

The script is based on the Prestashop docs: https://devdocs.prestashop.com/1.7/development/webservice/tutorials/change_product_image/

I'd be grateful for any advice.

×
×
  • Create New...