VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
413 stars 65 forks source link

Unable to get comments data #99

Closed team-wealthian closed 2 years ago

team-wealthian commented 2 years ago

I trying to integrate this module into my stapi project as per your documentation but i am getting {"data":null,"error":{"status":404,"name":"NotFoundError","message":"Not Found","details":{}}} error when ever I am trying make rest api get call for http://localhost:1337/comments/api::post.post:1

When I tried to navigate in comments section of admin portal, I can see my console as,

image

with my admin panel as,

image

content of my package.json file is,

{ "name": "app-name", "private": true, "version": "0.1.0", "description": "A Strapi application", "scripts": { "develop": "strapi develop", "start": "strapi start", "build": "strapi build", "strapi": "strapi" }, "dependencies": { "@aws-sdk/client-s3": "^3.48.0", "@strapi/plugin-i18n": "4.0.0", "@strapi/plugin-users-permissions": "4.0.0", "@strapi/provider-email-nodemailer": "^4.0.3", "@strapi/provider-email-sendgrid": "^4.0.3", "@strapi/provider-email-sendmail": "^4.0.0", "@strapi/strapi": "4.0.0", "@strapi/utils": "^4.0.0", "aws-sdk": "^2.892.0", "axios": "^0.24.0", "bad-words": "^3.0.4", "lodash": "^4.17.21", "nodemailer": "^6.7.2", "pg": "^8.7.1", "sendmail": "^1.6.1", "sqlite3": "5.0.2", "strapi-plugin-comments": "^2.0.0-beta.3", "strapi-provider-upload-aws-s3": "^3.6.8", "strapi-provider-upload-aws-s3-advanced": "^4.0.3" }, "author": { "name": "A Strapi developer" }, "strapi": { "uuid": "unique id" }, "engines": { "node": ">=12.x.x <=16.x.x", "npm": ">=6.0.0" }, "license": "MIT" }

installed node version is 15.14.0 npm version is 7.7.6

I have enabled all the setting for comments plugin for making a rest api call from setting tab> role for all users .

Content of my plugin.js is,

comments: { enabled: true, config: { enableUsers: false, }, badWords: false, moderatorRoles: ["Public"], approvalFlow: ["api::post.post"], entryLabel: { "*": ["Title", "title", "Name", "name", "Subject", "subject","id"], "api::post.post": ["id"], }, reportReasons: { MY_CUSTOM_REASON: "MY_CUSTOM_REASON", }, }

Can you please help me to fix this issue

cyp3rius commented 2 years ago

Hello @team-wealthian ,

First of all please upgrade used plugin version to the most recent one: rc.1

Do you have created entity with api::page.page with id: 1?

Try to add first comment using POST method and see if works as expected. Also while adding provilidges to the endpoints check the url (maybe base url of endpoint is different, that depends on your instance configuration)

team-wealthian commented 2 years ago

@cyp3rius We have upgraded with version rc.1. In we have configured our entity on api::post.post we can access the same using http://localhost:1337/api/posts

Now we have tried to make a post a call for

http://localhost:1337/comments/api::post.post:1

with request body as { "author": { "id": "11", "name": "Joe Doe", "email": "jdoe@sample.com", "avatar": "sample url" }, "content": "My sample response" }

in the postman i am getting an error,

**{"data":null,"error":{"status":400,"name":"Error","message":"invalid JSON, only supports object and array"}}**

and in in the console I am getting error as,

image

Please help

cyp3rius commented 2 years ago

Ok, so seems something with payload, how you are making the call? Which lib is used? Have you tried postman / any API test suite?

I would like to eliminate the data transform issues between API and client first.

Regards, Matt

team-wealthian commented 2 years ago

we are using postman. There is one thing that I have noted ...with graphql it is working pretty smoothly. Not sure why it is failing with rest api

cyp3rius commented 2 years ago

I've recognized what was wrong. Endpoints mentioned in the Readme.md were missing the api/ part so you've to use http://localhost:1337/api/comments/api::post.post:1 instead of http://localhost:1337/comments/api::post.post:1.

Documentation has been already fixed.

M1ck0 commented 2 years ago

@cyp3rius Docs are still not fixed, as you can see in the image.

image

cyp3rius commented 2 years ago

Will pick it up on Monday with some first commits