Chilkat Online Tools

C / Salesforce Platform APIs / List of Groups

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *additionalLabel;
    const char *announcement;
    const char *BannerPhotoUrl;
    const char *BannerPhotoVersionId;
    const char *v_Url;
    BOOL canHaveChatterGuests;
    const char *community;
    const char *description;
    const char *emailToChatterAddress;
    int fileCount;
    const char *id;
    const char *Text;
    const char *Title;
    BOOL isArchived;
    BOOL isAutoArchiveDisabled;
    BOOL isBroadcast;
    const char *lastFeedElementPostDate;
    int memberCount;
    const char *Color;
    const char *LargeIconUrl;
    const char *MediumIconUrl;
    const char *SmallIconUrl;
    const char *SvgIconUrl;
    const char *myRole;
    const char *Id;
    const char *mySubscriptionUrl;
    const char *name;
    const char *AdditionalLabel;
    const char *CommunityNickname;
    const char *CompanyName;
    const char *DisplayName;
    const char *FirstName;
    const char *ownerId;
    BOOL IsActive;
    BOOL IsInThisCommunity;
    const char *LastName;
    const char *MotifColor;
    const char *MotifLargeIconUrl;
    const char *MotifMediumIconUrl;
    const char *MotifSmallIconUrl;
    const char *MotifSvgIconUrl;
    const char *MySubscription;
    const char *Name;
    const char *Message;
    const char *FullEmailPhotoUrl;
    const char *LargePhotoUrl;
    const char *MediumPhotoUrl;
    const char *PhotoVersionId;
    const char *SmallPhotoUrl;
    const char *StandardEmailPhotoUrl;
    const char *PhotoUrl;
    const char *Reputation;
    const char *ownerTitle;
    const char *v_Type;
    const char *ownerUrl;
    const char *UserType;
    const char *pendingRequests;
    const char *photoFullEmailPhotoUrl;
    const char *photoLargePhotoUrl;
    const char *photoMediumPhotoUrl;
    const char *photoPhotoVersionId;
    const char *photoSmallPhotoUrl;
    const char *photoStandardEmailPhotoUrl;
    const char *photoUrl;
    const char *v_type;
    const char *url;
    const char *visibility;
    const char *currentPageUrl;
    const char *nextPageUrl;
    const char *previousPageUrl;
    int i;
    int count_i;

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

    http = CkHttp_Create();

    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttp_putAuthToken(http,"<access_token>");

    sbResponseBody = CkStringBuilder_Create();
    success = CkHttp_QuickGetSb(http,"https://domain.com/services/data/v{{version}}/chatter/groups",sbResponseBody);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttp_getLastStatus(http);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttp_lastHeader(http));
        printf("Failed.\n");
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "currentPageUrl": "/services/data/v58.0/chatter/groups",
    //   "groups": [
    //     {
    //       "additionalLabel": null,
    //       "announcement": null,
    //       "bannerPhoto": {
    //         "bannerPhotoUrl": "https://<my_domain>/profilephoto/0F9/B",
    //         "bannerPhotoVersionId": null,
    //         "url": "/services/data/v58.0/chatter/groups/0F9.../banner-photo"
    //       },
    //       "canHaveChatterGuests": false,
    //       "community": null,
    //       "description": "Test group",
    //       "emailToChatterAddress": "0F9...@post.2o-i6mbeaq.eu25.chatter.salesforce.com",
    //       "fileCount": 0,
    //       "id": "0F9...",
    //       "information": {
    //         "text": null,
    //         "title": null
    //       },
    //       "isArchived": false,
    //       "isAutoArchiveDisabled": false,
    //       "isBroadcast": false,
    //       "lastFeedElementPostDate": "2023-11-22T11:25:37.000Z",
    //       "memberCount": 1,
    //       "motif": {
    //         "color": "1B96FF",
    //         "largeIconUrl": "/img/icon/groups64.png",
    //         "mediumIconUrl": "/img/icon/groups32.png",
    //         "smallIconUrl": "/img/icon/groups16.png",
    //         "svgIconUrl": null
    //       },
    //       "myRole": "GroupOwner",
    //       "mySubscription": {
    //         "id": "0FB...",
    //         "url": "/services/data/v58.0/chatter/group-memberships/0FB..."
    //       },
    //       "name": "Test",
    //       "owner": {
    //         "additionalLabel": null,
    //         "communityNickname": "User1696423780773910041",
    //         "companyName": "Salesforce",
    //         "displayName": "Firstname",
    //         "firstName": "Firstname",
    //         "id": "005...",
    //         "isActive": true,
    //         "isInThisCommunity": true,
    //         "lastName": "Name",
    //         "motif": {
    //           "color": "1B96FF",
    //           "largeIconUrl": "/img/icon/profile64.png",
    //           "mediumIconUrl": "/img/icon/profile32.png",
    //           "smallIconUrl": "/img/icon/profile16.png",
    //           "svgIconUrl": null
    //         },
    //         "mySubscription": null,
    //         "name": "Firstname",
    //         "outOfOffice": {
    //           "message": ""
    //         },
    //         "photo": {
    //           "fullEmailPhotoUrl": "https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0IogXzXAXaYKJnuWCNQmXymRq?fromEmail=1",
    //           "largePhotoUrl": "https://<my_domain>/profilephoto/7292o000000oAgZ/F",
    //           "mediumPhotoUrl": "https://<my_domain>/profilephoto/7292o000000oAgZ/M",
    //           "photoVersionId": "729...",
    //           "smallPhotoUrl": "https://<my_domain>/profilephoto/7292o000000oAgZ/T",
    //           "standardEmailPhotoUrl": "https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0Ioi-dtynkoFWsl46as__TDFU?fromEmail=1",
    //           "url": "/services/data/v58.0/connect/user-profiles/005.../photo"
    //         },
    //         "reputation": null,
    //         "title": null,
    //         "type": "User",
    //         "url": "/services/data/v58.0/chatter/users/005...",
    //         "userType": "Internal"
    //       },
    //       "pendingRequests": null,
    //       "photo": {
    //         "fullEmailPhotoUrl": "https://<my_domain>/img/userprofile/default_group_profile_200_v2.png?fromEmail=1",
    //         "largePhotoUrl": "https://<my_domain>/profilephoto/0F9/F",
    //         "mediumPhotoUrl": "https://<my_domain>/profilephoto/0F9/M",
    //         "photoVersionId": null,
    //         "smallPhotoUrl": "https://<my_domain>/profilephoto/0F9/T",
    //         "standardEmailPhotoUrl": "https://<my_domain>/img/userprofile/default_group_profile_45_v2.png?fromEmail=1",
    //         "url": "/services/data/v58.0/chatter/groups/0F9.../photo"
    //       },
    //       "type": "CollaborationGroup",
    //       "url": "/services/data/v58.0/chatter/groups/0F9...",
    //       "visibility": "PublicAccess"
    //     }
    //   ],
    //   "nextPageUrl": null,
    //   "previousPageUrl": null
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    currentPageUrl = CkJsonObject_stringOf(jResp,"currentPageUrl");
    nextPageUrl = CkJsonObject_stringOf(jResp,"nextPageUrl");
    previousPageUrl = CkJsonObject_stringOf(jResp,"previousPageUrl");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"groups");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        additionalLabel = CkJsonObject_stringOf(jResp,"groups[i].additionalLabel");
        announcement = CkJsonObject_stringOf(jResp,"groups[i].announcement");
        BannerPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].bannerPhoto.bannerPhotoUrl");
        BannerPhotoVersionId = CkJsonObject_stringOf(jResp,"groups[i].bannerPhoto.bannerPhotoVersionId");
        v_Url = CkJsonObject_stringOf(jResp,"groups[i].bannerPhoto.url");
        canHaveChatterGuests = CkJsonObject_BoolOf(jResp,"groups[i].canHaveChatterGuests");
        community = CkJsonObject_stringOf(jResp,"groups[i].community");
        description = CkJsonObject_stringOf(jResp,"groups[i].description");
        emailToChatterAddress = CkJsonObject_stringOf(jResp,"groups[i].emailToChatterAddress");
        fileCount = CkJsonObject_IntOf(jResp,"groups[i].fileCount");
        id = CkJsonObject_stringOf(jResp,"groups[i].id");
        Text = CkJsonObject_stringOf(jResp,"groups[i].information.text");
        Title = CkJsonObject_stringOf(jResp,"groups[i].information.title");
        isArchived = CkJsonObject_BoolOf(jResp,"groups[i].isArchived");
        isAutoArchiveDisabled = CkJsonObject_BoolOf(jResp,"groups[i].isAutoArchiveDisabled");
        isBroadcast = CkJsonObject_BoolOf(jResp,"groups[i].isBroadcast");
        lastFeedElementPostDate = CkJsonObject_stringOf(jResp,"groups[i].lastFeedElementPostDate");
        memberCount = CkJsonObject_IntOf(jResp,"groups[i].memberCount");
        Color = CkJsonObject_stringOf(jResp,"groups[i].motif.color");
        LargeIconUrl = CkJsonObject_stringOf(jResp,"groups[i].motif.largeIconUrl");
        MediumIconUrl = CkJsonObject_stringOf(jResp,"groups[i].motif.mediumIconUrl");
        SmallIconUrl = CkJsonObject_stringOf(jResp,"groups[i].motif.smallIconUrl");
        SvgIconUrl = CkJsonObject_stringOf(jResp,"groups[i].motif.svgIconUrl");
        myRole = CkJsonObject_stringOf(jResp,"groups[i].myRole");
        Id = CkJsonObject_stringOf(jResp,"groups[i].mySubscription.id");
        mySubscriptionUrl = CkJsonObject_stringOf(jResp,"groups[i].mySubscription.url");
        name = CkJsonObject_stringOf(jResp,"groups[i].name");
        AdditionalLabel = CkJsonObject_stringOf(jResp,"groups[i].owner.additionalLabel");
        CommunityNickname = CkJsonObject_stringOf(jResp,"groups[i].owner.communityNickname");
        CompanyName = CkJsonObject_stringOf(jResp,"groups[i].owner.companyName");
        DisplayName = CkJsonObject_stringOf(jResp,"groups[i].owner.displayName");
        FirstName = CkJsonObject_stringOf(jResp,"groups[i].owner.firstName");
        ownerId = CkJsonObject_stringOf(jResp,"groups[i].owner.id");
        IsActive = CkJsonObject_BoolOf(jResp,"groups[i].owner.isActive");
        IsInThisCommunity = CkJsonObject_BoolOf(jResp,"groups[i].owner.isInThisCommunity");
        LastName = CkJsonObject_stringOf(jResp,"groups[i].owner.lastName");
        MotifColor = CkJsonObject_stringOf(jResp,"groups[i].owner.motif.color");
        MotifLargeIconUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.motif.largeIconUrl");
        MotifMediumIconUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.motif.mediumIconUrl");
        MotifSmallIconUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.motif.smallIconUrl");
        MotifSvgIconUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.motif.svgIconUrl");
        MySubscription = CkJsonObject_stringOf(jResp,"groups[i].owner.mySubscription");
        Name = CkJsonObject_stringOf(jResp,"groups[i].owner.name");
        Message = CkJsonObject_stringOf(jResp,"groups[i].owner.outOfOffice.message");
        FullEmailPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.photo.fullEmailPhotoUrl");
        LargePhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.photo.largePhotoUrl");
        MediumPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.photo.mediumPhotoUrl");
        PhotoVersionId = CkJsonObject_stringOf(jResp,"groups[i].owner.photo.photoVersionId");
        SmallPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.photo.smallPhotoUrl");
        StandardEmailPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.photo.standardEmailPhotoUrl");
        PhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.photo.url");
        Reputation = CkJsonObject_stringOf(jResp,"groups[i].owner.reputation");
        ownerTitle = CkJsonObject_stringOf(jResp,"groups[i].owner.title");
        v_Type = CkJsonObject_stringOf(jResp,"groups[i].owner.type");
        ownerUrl = CkJsonObject_stringOf(jResp,"groups[i].owner.url");
        UserType = CkJsonObject_stringOf(jResp,"groups[i].owner.userType");
        pendingRequests = CkJsonObject_stringOf(jResp,"groups[i].pendingRequests");
        photoFullEmailPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].photo.fullEmailPhotoUrl");
        photoLargePhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].photo.largePhotoUrl");
        photoMediumPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].photo.mediumPhotoUrl");
        photoPhotoVersionId = CkJsonObject_stringOf(jResp,"groups[i].photo.photoVersionId");
        photoSmallPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].photo.smallPhotoUrl");
        photoStandardEmailPhotoUrl = CkJsonObject_stringOf(jResp,"groups[i].photo.standardEmailPhotoUrl");
        photoUrl = CkJsonObject_stringOf(jResp,"groups[i].photo.url");
        v_type = CkJsonObject_stringOf(jResp,"groups[i].type");
        url = CkJsonObject_stringOf(jResp,"groups[i].url");
        visibility = CkJsonObject_stringOf(jResp,"groups[i].visibility");
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/chatter/groups

Postman Collection Item JSON

{
  "name": "List of Groups",
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    },
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "protocolProfileBehavior": {
    "disabledSystemHeaders": {}
  },
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/chatter/groups",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "chatter",
        "groups"
      ]
    },
    "description": "A list of all the groups in the organization. Get information about groups or create a group.\n\nhttps://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_groups_ListOfGroups.htm"
  },
  "response": [
    {
      "name": "Successful List of Groups",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/chatter/groups",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "chatter",
            "groups"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Wed, 22 Nov 2023 11:25:52 GMT"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=63072000; includeSubDomains"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "X-Robots-Tag",
          "value": "none"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache,must-revalidate,max-age=0,no-store,private"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=UTF-8"
        },
        {
          "key": "Vary",
          "value": "Accept-Encoding"
        },
        {
          "key": "Content-Encoding",
          "value": "gzip"
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"currentPageUrl\": \"/services/data/v58.0/chatter/groups\",\n    \"groups\": [\n        {\n            \"additionalLabel\": null,\n            \"announcement\": null,\n            \"bannerPhoto\": {\n                \"bannerPhotoUrl\": \"https://<my_domain>/profilephoto/0F9/B\",\n                \"bannerPhotoVersionId\": null,\n                \"url\": \"/services/data/v58.0/chatter/groups/0F9.../banner-photo\"\n            },\n            \"canHaveChatterGuests\": false,\n            \"community\": null,\n            \"description\": \"Test group\",\n            \"emailToChatterAddress\": \"0F9...@post.2o-i6mbeaq.eu25.chatter.salesforce.com\",\n            \"fileCount\": 0,\n            \"id\": \"0F9...\",\n            \"information\": {\n                \"text\": null,\n                \"title\": null\n            },\n            \"isArchived\": false,\n            \"isAutoArchiveDisabled\": false,\n            \"isBroadcast\": false,\n            \"lastFeedElementPostDate\": \"2023-11-22T11:25:37.000Z\",\n            \"memberCount\": 1,\n            \"motif\": {\n                \"color\": \"1B96FF\",\n                \"largeIconUrl\": \"/img/icon/groups64.png\",\n                \"mediumIconUrl\": \"/img/icon/groups32.png\",\n                \"smallIconUrl\": \"/img/icon/groups16.png\",\n                \"svgIconUrl\": null\n            },\n            \"myRole\": \"GroupOwner\",\n            \"mySubscription\": {\n                \"id\": \"0FB...\",\n                \"url\": \"/services/data/v58.0/chatter/group-memberships/0FB...\"\n            },\n            \"name\": \"Test\",\n            \"owner\": {\n                \"additionalLabel\": null,\n                \"communityNickname\": \"User1696423780773910041\",\n                \"companyName\": \"Salesforce\",\n                \"displayName\": \"Firstname\",\n                \"firstName\": \"Firstname\",\n                \"id\": \"005...\",\n                \"isActive\": true,\n                \"isInThisCommunity\": true,\n                \"lastName\": \"Name\",\n                \"motif\": {\n                    \"color\": \"1B96FF\",\n                    \"largeIconUrl\": \"/img/icon/profile64.png\",\n                    \"mediumIconUrl\": \"/img/icon/profile32.png\",\n                    \"smallIconUrl\": \"/img/icon/profile16.png\",\n                    \"svgIconUrl\": null\n                },\n                \"mySubscription\": null,\n                \"name\": \"Firstname\",\n                \"outOfOffice\": {\n                    \"message\": \"\"\n                },\n                \"photo\": {\n                    \"fullEmailPhotoUrl\": \"https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0IogXzXAXaYKJnuWCNQmXymRq?fromEmail=1\",\n                    \"largePhotoUrl\": \"https://<my_domain>/profilephoto/7292o000000oAgZ/F\",\n                    \"mediumPhotoUrl\": \"https://<my_domain>/profilephoto/7292o000000oAgZ/M\",\n                    \"photoVersionId\": \"729...\",\n                    \"smallPhotoUrl\": \"https://<my_domain>/profilephoto/7292o000000oAgZ/T\",\n                    \"standardEmailPhotoUrl\": \"https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0Ioi-dtynkoFWsl46as__TDFU?fromEmail=1\",\n                    \"url\": \"/services/data/v58.0/connect/user-profiles/005.../photo\"\n                },\n                \"reputation\": null,\n                \"title\": null,\n                \"type\": \"User\",\n                \"url\": \"/services/data/v58.0/chatter/users/005...\",\n                \"userType\": \"Internal\"\n            },\n            \"pendingRequests\": null,\n            \"photo\": {\n                \"fullEmailPhotoUrl\": \"https://<my_domain>/img/userprofile/default_group_profile_200_v2.png?fromEmail=1\",\n                \"largePhotoUrl\": \"https://<my_domain>/profilephoto/0F9/F\",\n                \"mediumPhotoUrl\": \"https://<my_domain>/profilephoto/0F9/M\",\n                \"photoVersionId\": null,\n                \"smallPhotoUrl\": \"https://<my_domain>/profilephoto/0F9/T\",\n                \"standardEmailPhotoUrl\": \"https://<my_domain>/img/userprofile/default_group_profile_45_v2.png?fromEmail=1\",\n                \"url\": \"/services/data/v58.0/chatter/groups/0F9.../photo\"\n            },\n            \"type\": \"CollaborationGroup\",\n            \"url\": \"/services/data/v58.0/chatter/groups/0F9...\",\n            \"visibility\": \"PublicAccess\"\n        }\n    ],\n    \"nextPageUrl\": null,\n    \"previousPageUrl\": null\n}"
    }
  ]
}