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
410 stars 64 forks source link

"No content received" #28

Closed lesleyracs closed 3 years ago

lesleyracs commented 3 years ago

Hi, I installed the plugin following the instruction and added it to contentType, but I can't seem to make a successful POST request I keeping getting the following error

server-eeror

I have the following in my package.json

"knex": "^0.21.14", "sqlite3": "^5.0.0", "strapi": "3.4.1", "strapi-admin": "3.4.1", "strapi-connector-bookshelf": "^3.4.1", "strapi-connector-mongoose": "3.4.1", "strapi-plugin-comments": "^1.0.1-beta.2", "strapi-plugin-content-manager": "3.4.1", "strapi-plugin-content-type-builder": "3.4.1", "strapi-plugin-email": "3.4.1", "strapi-plugin-graphql": "3.4.1", "strapi-plugin-upload": "3.4.1", "strapi-plugin-users-permissions": "3.4.1", "strapi-utils": "3.4.1"

Any help will be appreciated

cyp3rius commented 3 years ago

Hi @lesleyracs ,

Try to add following property to your request body:

    "related": [{
        "refId": 1,
        "ref": "article",
        "field": "comments"
    }] 
lesleyracs commented 3 years ago

Thanks, it worked.

kwiat1990 commented 3 years ago

I have encountered the very same problem, although the posted solution didn't work for me. I get still the same error and it doesn't matter how the body of the request look like.

My Strapi version is 3.4.1 and I have enabled permission for posting comments.

cyp3rius commented 3 years ago

Catched on zoom and solved :)

chandrastrez commented 3 years ago

Hi, i also had the same problem but with axios and formdata, in postman it worked.

      const formData = new FormData();
      formData.append('data', JSON.stringify(this.comment))

      this.$axios.post('/comments/article:'+this.relatedid, formData)
      .then(response => {
        console.log(response)
      })
      .catch(error => {
        console.log(error)
      })

In console

Screenshot_5

Strapi version 3.4.5

cyp3rius commented 3 years ago

@chandrastrez thats probably the issue with header Content-Type in axios as by default it send plain text. Force it to be a json and will work.

thats purely axios case, not the plugin.

chandrastrez commented 3 years ago

Thanks it worked, with set header content type in axios