Dear devs,

JSON API allows to post and edit Drupal comments, which is great.

However, the relationship "uid" is only post-able if the permission "administer comments" is granted to the user role's. That may be an intended behaviour.

Nonetheless, when i post a node putting "uid" directly in the "data" of the request and not the relationships section, it works and drupal attach the node to the author automatically.

Now, when i post a comment putting "uid" in the data section of the request, it doesn't work and the uid relationships returns as anonymous after creation...

For exemple:

  "data": {   "uid": {
                                "data": {
                                    "type": "user--user",
                                    "id": this.node.uid.data.id
                                },
                            }
                        } 

In other words, the only way i found for the user to post comments as something else as anonymous, is to grant this permission to modify the comments of all users, which is far from the solution i want to opt in in a production website.

Is there some workaround to bind the comment to the posting user without granting a global permission to add and delete all comments ? Ultimately the behaviour is very different from a common drupal "node", which implicates additional front end works...

Thank you in advance for your enlightenment.

Comments

hfm created an issue. See original summary.

hfm’s picture

Issue summary: View changes
hfm’s picture

Issue summary: View changes
Thithi32’s picture

Up
We're having a similar dilema: we need to post comments without admin permission and it does't work. Is there a workaround?
Thx!