I have successfully install this module Reviews/Rating
I call this url="/V1/review/mine/post" method="POST"
.I don't know what data is passed in body of this URL.
-
can you share all the files of your program– shwetaCommented Mar 18, 2019 at 11:43
-
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review– Manashvi BirlaCommented Mar 18, 2019 at 12:13
-
I face the same problem plz tell me what i do now.– madhuCommented Dec 6, 2019 at 8:54
1 Answer
If you inspect the module code etc/webapi.xml
you will see following code
<route url="/V1/review/mine/post" method="POST">
<service class="Ipragmatech\Ipreview\Api\ReviewInterface" method="writeReviews"/>
<resources>
<resource ref="self" />
</resources>
<data>
<parameter name="customer_id" force="true">%customer_id%</parameter>
</data>
</route>
And API signature in \Ipreview\Api\ReviewInterface
/**
* Added review and rating for the product.
* @param int $productId
* @param string $title
* @param string $nickname
* @param string $detail
* @param Ipragmatech\Ipreview\Api\Data\RatingInterface[] $ratingData
* @param int $customer_id
* @param int $store_id
* @return boolean
*
*/
public function writeReviews(
$productId,
$nickname,
$title,
$detail,
$ratingData,
$customer_id = null,
$storeId
);
So whenever you are setting ref as self the data will be taken from the token passed as bearer token and data node below it specify which data has to be taken form the the token . In above case it is customer ID , it also can be token . $customer_id will be taken from token and rest of the params can be passed in below body format
{
"productId": "10",
"nickname": "Mann",
"title": "Cool, Nice product",
"detail": "This is nice product. I recommended this product.",
"ratingData": [{
"rating_id": "3",
"ratingCode": "price",
"ratingValue": "5"
}, {
"rating_id": "4",
"ratingCode": "Rating",
"ratingValue": "2"
}],
"storeId": "1"
}
-
I will pass this data as following: {"productId":"8","nickname":"lovely","title":"Nice Product","detail":"This is nice product","ratingData":[{"ratingValue":"2"}],"storeId":"1"}.But its showing error :[{"status":false,"message":"We can't post your review right now. SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'value' cannot be null, query was: INSERT INTO
rating_option_vote
(option_id
,review_id
,percent
,value
,remote_ip
,remote_ip_long
,customer_id
,entity_pk_value
,rating_id
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"}]. Commented May 10, 2018 at 8:15 -
@LovelySetia updated the answer , Please accept the answer if it works for you Commented May 10, 2018 at 8:59
-
it is throwing the same error for me too, what code changes needs to be done?– sahanaCommented Sep 26, 2018 at 5:51
-