- Issue created by @sachbearbeiter
- 🇨🇦Canada dylan donkersgoed London, Ontario
In theory I think the way to do this would be by creating a group membership via the API. Unfortunately I think https://www.drupal.org/project/group/issues/2872645 🐛 Creating `Group` content is impossible via REST, JSON:API and GraphQL due to `$context['group']` being required in checking `create` access Needs work would prevent that. Though someone more knowledgeable about the module's internals might wish to jump in and correct me - I am not a maintainer.
There is an MR attached to that issue. I have never tested it, but it'd probably be worth looking at. I think if you did have the patch you could do something like this with jsonapi to add a group membership:
curl --location --request POST 'https:/cms.foo.com/jsonapi/group_content/subsite-group_membership' \ --header 'Accept: application/vnd.api+json' \ --header 'Content-Type: application/vnd.api+json' \ --header '<omitted>' \ --data-raw '{ "data": { "type": "group_content--subsite-group_membership", "attributes": { "group_roles": [ "subsite-group_administrator" ] }, "relationships": { "gid": { "data": { "type": "group--subsite", "id": "a6aaabbb-2e59-40c3-b7d2-367e66a4d6a5" } }, "entity_id": { "data": { "type": "user--user", "id": "d19e7446-4b89-4884-9acf-d921e21edc12" } } } } }'