I am Trying to upload image using rest api but it gives
string(116) "{"message":"Consumer is not authorized to access %resources","parameters":{"resources":"Magento_Catalog::products"}}"
My code is
$configProductData=array(
"product"=>array(
"sku"=>"ABC_123456",
"name"=> "My Product Title Listing",
"price"=> 425.99,
"status"=>1,
"visibility"=> 4,
"typeId"=> "simple",
"weight"=> 15,
"mediaGalleryEntries"=>array(
"mediaType"=>"image",
"label"=> "abc_123456_image",
"position"=> 0,
"disabled"=> false,
"file"=> "http://www.url.to/product.png",
"content"=>array(
"base64EncodedData"=>"string",
"type"=> "string",
"name"=> "string"
)
)
),
"saveOptions"=> true
);
$product_url= "http://demo.store.com/magento2/project-community-edition/index.php/rest/V1/products";
$productData = json_encode(array('product' => $configProductData));
$setHaders = array('Content-Type:application/json','Authorization:Bearer '.$adminToken);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $product_url);
curl_setopt($ch,CURLOPT_POSTFIELDS, $configProductData);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $setHaders);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
I can create products without any issue.But image upload is not working