Chilkat Online Tools

delphiDll / Atlassian Confluence Cloud / Add member to group by groupId

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
resp: HCkHttpResponse;

begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

http := CkHttp_Create();

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "accountId": "<string>"
// }

json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'accountId','<string>');

// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,'<access_token>');
CkHttp_SetRequestHeader(http,'Content-Type','application/json');

resp := CkHttp_PostJson3(http,'https://your-domain.atlassian.net/wiki/rest/api/group/userByGroupId?groupId=<string>','application/json',json);
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttpResponse_Dispose(resp);

CkHttp_Dispose(http);
CkJsonObject_Dispose(json);

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-d '{
    "accountId": "<string>"
}'
https://your-domain.atlassian.net/wiki/rest/api/group/userByGroupId?groupId=<string>

Postman Collection Item JSON

{
  "name": "Add member to group by groupId",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"accountId\": \"<string>\"\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/api/group/userByGroupId?groupId=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "group",
        "userByGroupId"
      ],
      "query": [
        {
          "key": "groupId",
          "value": "<string>",
          "description": "(Required) GroupId of the group whose membership is updated"
        }
      ]
    },
    "description": "Adds a user as a member in a group represented by its groupId\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nUser must be a site admin."
  },
  "response": [
    {
      "name": "Returned if the group was created successfully.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/group/userByGroupId?groupId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "group",
            "userByGroupId"
          ],
          "query": [
            {
              "key": "groupId",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the groupId or accountId are missing or invalid.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/group/userByGroupId?groupId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "group",
            "userByGroupId"
          ],
          "query": [
            {
              "key": "groupId",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the calling user is not logged in to Confluence.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/group/userByGroupId?groupId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "group",
            "userByGroupId"
          ],
          "query": [
            {
              "key": "groupId",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the user is not a site admin.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/group/userByGroupId?groupId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "group",
            "userByGroupId"
          ],
          "query": [
            {
              "key": "groupId",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "If no user group by the give name exists.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/group/userByGroupId?groupId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "group",
            "userByGroupId"
          ],
          "query": [
            {
              "key": "groupId",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}