Add reviews JSON error 403
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Add reviews JSON error 403
When trying to leave a review to the purchased goods: "You can only add a review if you have ordered a product"
Code: Select all
const url = '/jsonapi/customer?related=review'
const params = {'data': [{
'attributes': {
'review.domain': 'product',
'review.refid': $('#modalReview .review-form-hidden').val(),
'review.name': $('#modalReview .review-form-name').val(),
'review.rating': $('#modalReview .review-form-radio:checked').val(),
'review.comment': $('#modalReview .review-form-textarea').val()
}
}]}
$.ajax({
url: url,
method: 'POST',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
dataType: 'json',
data: JSON.stringify(params)
}).done(function(result) {
console.log(result)
})
Re: Add reviews JSON error 403
Seems like the documentation isn't up to date. There have been another check introduced so it's required to pass the ID of the ordered product too to avoid fake reviews. Please try:
Code: Select all
const params = {'data': [{
'attributes': {
'review.domain': 'product',
'review.orderproductid': $('#modalReview .review-form-ordprodid').val(),
'review.refid': $('#modalReview .review-form-hidden').val(),
'review.name': $('#modalReview .review-form-name').val(),
'review.rating': $('#modalReview .review-form-radio:checked').val(),
'review.comment': $('#modalReview .review-form-textarea').val()
}
}]}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Add reviews JSON error 403
Thansk! It is workingaimeos wrote: ↑26 Nov 2020, 13:37 Seems like the documentation isn't up to date. There have been another check introduced so it's required to pass the ID of the ordered product too to avoid fake reviews. Please try:Code: Select all
const params = {'data': [{ 'attributes': { 'review.domain': 'product', 'review.orderproductid': $('#modalReview .review-form-ordprodid').val(), 'review.refid': $('#modalReview .review-form-hidden').val(), 'review.name': $('#modalReview .review-form-name').val(), 'review.rating': $('#modalReview .review-form-radio:checked').val(), 'review.comment': $('#modalReview .review-form-textarea').val() } }]}
Re: Add reviews JSON error 403
Great, documentation has been updated too.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star