Chilkat Online Tools

Go / Salesforce Platform APIs / List of Groups

Back to Collection Items

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

    http := chilkat.NewHttp()
    var success bool

    // Adds the "Authorization: Bearer <access_token>" header.
    http.SetAuthToken("<access_token>")

    sbResponseBody := chilkat.NewStringBuilder()
    success = http.QuickGetSb("https://domain.com/services/data/v{{version}}/chatter/groups",sbResponseBody)
    if success == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        sbResponseBody.DisposeStringBuilder()
        return
    }

    jResp := chilkat.NewJsonObject()
    jResp.LoadSb(sbResponseBody)
    jResp.SetEmitCompact(false)

    fmt.Println("Response Body:")
    fmt.Println(*jResp.Emit())

    respStatusCode := http.LastStatus()
    fmt.Println("Response Status Code = ", respStatusCode)
    if respStatusCode >= 400 {
        fmt.Println("Response Header:")
        fmt.Println(http.LastHeader())
        fmt.Println("Failed.")
        http.DisposeHttp()
        sbResponseBody.DisposeStringBuilder()
        jResp.DisposeJsonObject()
        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

    var additionalLabel *string = new(string)
    var announcement *string = new(string)
    var BannerPhotoUrl *string = new(string)
    var BannerPhotoVersionId *string = new(string)
    var v_Url_Ref.html">Url *string = new(string)
    var canHaveChatterGuests bool
    var community *string = new(string)
    var description *string = new(string)
    var emailToChatterAddress *string = new(string)
    var fileCount int
    var id *string = new(string)
    var Text *string = new(string)
    var Title *string = new(string)
    var isArchived bool
    var isAutoArchiveDisabled bool
    var isBroadcast bool
    var lastFeedElementPostDate *string = new(string)
    var memberCount int
    var Color *string = new(string)
    var LargeIconUrl *string = new(string)
    var MediumIconUrl *string = new(string)
    var SmallIconUrl *string = new(string)
    var SvgIconUrl *string = new(string)
    var myRole *string = new(string)
    var Id *string = new(string)
    var mySubscriptionUrl *string = new(string)
    var name *string = new(string)
    var AdditionalLabel *string = new(string)
CommunityNick    var name *string = new(string)
Company    var Name *string = new(string)
    var DisplayName *string = new(string)
First    var Name *string = new(string)
    var ownerId *string = new(string)
    var IsActive bool
    var IsInThisCommunity bool
    var LastName *string = new(string)
Motif    var Color *string = new(string)
    var MotifLargeIconUrl *string = new(string)
Motif    var MediumIconUrl *string = new(string)
Motif    var SmallIconUrl *string = new(string)
Motif    var SvgIconUrl *string = new(string)
    var MySubscription *string = new(string)
    var Name *string = new(string)
    var Message *string = new(string)
FullEmail    var PhotoUrl *string = new(string)
Large    var PhotoUrl *string = new(string)
Medium    var PhotoUrl *string = new(string)
    var PhotoVersionId *string = new(string)
Small    var PhotoUrl *string = new(string)
StandardEmail    var PhotoUrl *string = new(string)
    var PhotoUrl *string = new(string)
    var Reputation *string = new(string)
    var ownerTitle *string = new(string)
    var v_Type *string = new(string)
    var ownerUrl *string = new(string)
    var UserType *string = new(string)
    var pendingRequests *string = new(string)
    var photoFullEmailPhotoUrl *string = new(string)
photoLarge    var PhotoUrl *string = new(string)
    var photoMediumPhotoUrl *string = new(string)
    var photoPhotoVersionId *string = new(string)
    var photoSmallPhotoUrl *string = new(string)
    var photoStandardEmailPhotoUrl *string = new(string)
    var photoUrl *string = new(string)
    var v_type *string = new(string)
    var url *string = new(string)
    var visibility *string = new(string)

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


    http.DisposeHttp()
    sbResponseBody.DisposeStringBuilder()
    jResp.DisposeJsonObject()

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}"
    }
  ]
}