Problem/Motivation

I'm trying to create node content type inside a specific group with Postman and the REST endpoint : /entity/group_relationship

Steps to reproduce

Drupal 9.4.8 / PHP 8.0
group 3.0.x-dev

After creating a group, trying to post a content with restfull api and postman

The Postman request is :
{
"data": {
"type": "group_relationship--projets_XYZ-b5856fc584d18c4",
"attributes": {
"langcode": "en",
"label": "article test",
"plugin_id": "group_node:article",
},
"relationships": {
"group_relationship_type": {
"data": {
"type": "group_relationship_type--group_relationship_type",
"id": "ed2bfcd9-fbe6-4981-b241-e652b4eb250d",
"meta": {
"drupal_internal__target_id": "projets_XYZ-b5856fc584d18c4"
}
},
},
"gid": {
"data": {
"type": "group--projets_XYZ",
"id": "4f379739-216f-4ed7-bd7f-12d2e6124a82",
"meta": {
"drupal_internal__target_id": 2
}
},
},
"group_type": {
"data": {
"type": "group_type--group_type",
"id": "2f9b44d2-08b8-4ac2-93fa-fa336065b8f1",
"meta": {
"drupal_internal__target_id": "projets_XYZ"
}
},
},
"entity_id": {
"data": {
"type": "node--article",
},
}
}
}
}

The logs error in Drupal are :

PHP Warning :
Warning: Undefined array key "group" in Drupal\group\Entity\Access\GroupRelationshipAccessControlHandler->checkCreateAccess() (line 61 of /var/www/vhosts/septembre.io/fed.septembre.io/modules/contrib/group/src/Entity/Access/GroupRelationshipAccessControlHandler.php)

And :
TypeError: Drupal\group\Plugin\Group\RelationHandler\GroupMembershipAccessControl::relationshipCreateAccess(): Argument #1 ($group) must be of type Drupal\group\Entity\GroupInterface, null given,

I don't understand which parameter and how it has to be formatted in postman to create this simple content.

Comments

clement_09 created an issue. See original summary.

clement_09’s picture

Priority: Major » Normal
clement_09’s picture

apaderno’s picture

Title: Create new node content inside a groupe via REST API or JSONAPI » Create new node content inside a group via REST API or JSONAPI
Assigned: clement_09 » Unassigned
Issue tags: -Needs documentation, -API Documentation, -Headless Drupal