I'm trying to access the REST Endpoints:

POST /V1/products/special-price
POST /V1/products/special-price-information
POST /V1/products/special-price-delete

I want to achieve this through PHP code however i'm finding it hard to understand just how to access them. I want to be able to GET the special prices of specific products. Any direction would be a help.


1 Answer 1


Try below code.

$productSpecialUrl=$url. "rest/V1/products/special-price";

//get admin access token
$ch = curl_init();
$data = array("username" => $username, "password" => $password);
$dataString = json_encode($data);

$ch = curl_init($tokenUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
$token = curl_exec($ch);
$requestPayload = json_encode(array(array('price' => 100, 'store_id' => 1, 'sku' => 'sku123', 'price_from' => date, 'price_to' => date )));
$ch = curl_init($productSpecialUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestPayload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));

$result = curl_exec($ch);

$result = json_decode($result, 1);
echo '<pre>';print_r($result);

Let me know if you need further help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.