Comment on page
Product Review
get each products review and write review for a product
post
https://<domain>/<api prefix>/<version>/commerce/product/product-review/
Node
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
'headers': {
'apikey': '<api key>',
'Authorization': 'Bearer <access token>',
},
formData: {
'comment': '<comment>',
'stars': '<star count>',
'bundle': '<bundle id>'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('bundle' => '<bundle_id>','comment' => '<>comment','stars' => '<stars_count>'),
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access token>',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Status code | Error Type | Field | Description |
400 | Validation Error | bundle | Bundle id is required. This field may not be blank. Product with bundle id not exist. |
400 | Validation Error | comment | comment is required |
400 | Validation Error | stars | stars count is required |
get
https://<domain>/<api prefix>/<version>/commerce/product/product-review/
All Reviews from different users of a product are fetched in product details api.
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
'headers': {
'apikey': '<api key>',
'Authorization': 'Bearer <access token>',
'Cookie': 'defult_store_slug=admin_store; store_user=admin_store'
},
formData: {
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://<domain>/<api prefix>/<version>/commerce/product/product-review/');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '<api key>',
'Authorization' => 'Bearer <access token>',
'Cookie' => 'defult_store_slug=admin_store; store_user=admin_store'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Status Code | Error Type | Field | Description |
400 | Validation Error | bundle_id | Bundle id is required. This field may not be blank. Product with bundle id not exist. |
Last modified 2yr ago