Chilkat Online Tools

PowerBuilder / Salesforce Platform APIs / List of Groups

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_AdditionalLabel
string ls_Announcement
string ls_BannerPhotoUrl
string ls_BannerPhotoVersionId
string ls_V_Url
integer li_CanHaveChatterGuests
string ls_Community
string ls_Description
string ls_EmailToChatterAddress
integer li_FileCount
string ls_Id
string ls_Text
string ls_Title
integer li_IsArchived
integer li_IsAutoArchiveDisabled
integer li_IsBroadcast
string ls_LastFeedElementPostDate
integer li_MemberCount
string ls_Color
string ls_LargeIconUrl
string ls_MediumIconUrl
string ls_SmallIconUrl
string ls_SvgIconUrl
string ls_MyRole
string ls_Id
string ls_MySubscriptionUrl
string ls_Name
string ls_AdditionalLabel
string ls_CommunityNickname
string ls_CompanyName
string ls_DisplayName
string ls_FirstName
string ls_OwnerId
integer li_IsActive
integer li_IsInThisCommunity
string ls_LastName
string ls_MotifColor
string ls_MotifLargeIconUrl
string ls_MotifMediumIconUrl
string ls_MotifSmallIconUrl
string ls_MotifSvgIconUrl
string ls_MySubscription
string ls_Name
string ls_Message
string ls_FullEmailPhotoUrl
string ls_LargePhotoUrl
string ls_MediumPhotoUrl
string ls_PhotoVersionId
string ls_SmallPhotoUrl
string ls_StandardEmailPhotoUrl
string ls_PhotoUrl
string ls_Reputation
string ls_OwnerTitle
string ls_V_Type
string ls_OwnerUrl
string ls_UserType
string ls_PendingRequests
string ls_PhotoFullEmailPhotoUrl
string ls_PhotoLargePhotoUrl
string ls_PhotoMediumPhotoUrl
string ls_PhotoPhotoVersionId
string ls_PhotoSmallPhotoUrl
string ls_PhotoStandardEmailPhotoUrl
string ls_PhotoUrl
string ls_V_type
string ls_Url
string ls_Visibility
string ls_CurrentPageUrl
string ls_NextPageUrl
string ls_PreviousPageUrl
integer i
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://domain.com/services/data/v{{version}}/chatter/groups",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// 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

ls_CurrentPageUrl = loo_JResp.StringOf("currentPageUrl")
ls_NextPageUrl = loo_JResp.StringOf("nextPageUrl")
ls_PreviousPageUrl = loo_JResp.StringOf("previousPageUrl")
i = 0
li_Count_i = loo_JResp.SizeOfArray("groups")
do while i < li_Count_i
    loo_JResp.I = i
    ls_AdditionalLabel = loo_JResp.StringOf("groups[i].additionalLabel")
    ls_Announcement = loo_JResp.StringOf("groups[i].announcement")
    ls_BannerPhotoUrl = loo_JResp.StringOf("groups[i].bannerPhoto.bannerPhotoUrl")
    ls_BannerPhotoVersionId = loo_JResp.StringOf("groups[i].bannerPhoto.bannerPhotoVersionId")
    ls_V_Url = loo_JResp.StringOf("groups[i].bannerPhoto.url")
    li_CanHaveChatterGuests = loo_JResp.BoolOf("groups[i].canHaveChatterGuests")
    ls_Community = loo_JResp.StringOf("groups[i].community")
    ls_Description = loo_JResp.StringOf("groups[i].description")
    ls_EmailToChatterAddress = loo_JResp.StringOf("groups[i].emailToChatterAddress")
    li_FileCount = loo_JResp.IntOf("groups[i].fileCount")
    ls_Id = loo_JResp.StringOf("groups[i].id")
    ls_Text = loo_JResp.StringOf("groups[i].information.text")
    ls_Title = loo_JResp.StringOf("groups[i].information.title")
    li_IsArchived = loo_JResp.BoolOf("groups[i].isArchived")
    li_IsAutoArchiveDisabled = loo_JResp.BoolOf("groups[i].isAutoArchiveDisabled")
    li_IsBroadcast = loo_JResp.BoolOf("groups[i].isBroadcast")
    ls_LastFeedElementPostDate = loo_JResp.StringOf("groups[i].lastFeedElementPostDate")
    li_MemberCount = loo_JResp.IntOf("groups[i].memberCount")
    ls_Color = loo_JResp.StringOf("groups[i].motif.color")
    ls_LargeIconUrl = loo_JResp.StringOf("groups[i].motif.largeIconUrl")
    ls_MediumIconUrl = loo_JResp.StringOf("groups[i].motif.mediumIconUrl")
    ls_SmallIconUrl = loo_JResp.StringOf("groups[i].motif.smallIconUrl")
    ls_SvgIconUrl = loo_JResp.StringOf("groups[i].motif.svgIconUrl")
    ls_MyRole = loo_JResp.StringOf("groups[i].myRole")
    ls_Id = loo_JResp.StringOf("groups[i].mySubscription.id")
    ls_MySubscriptionUrl = loo_JResp.StringOf("groups[i].mySubscription.url")
    ls_Name = loo_JResp.StringOf("groups[i].name")
    ls_AdditionalLabel = loo_JResp.StringOf("groups[i].owner.additionalLabel")
    ls_CommunityNickname = loo_JResp.StringOf("groups[i].owner.communityNickname")
    ls_CompanyName = loo_JResp.StringOf("groups[i].owner.companyName")
    ls_DisplayName = loo_JResp.StringOf("groups[i].owner.displayName")
    ls_FirstName = loo_JResp.StringOf("groups[i].owner.firstName")
    ls_OwnerId = loo_JResp.StringOf("groups[i].owner.id")
    li_IsActive = loo_JResp.BoolOf("groups[i].owner.isActive")
    li_IsInThisCommunity = loo_JResp.BoolOf("groups[i].owner.isInThisCommunity")
    ls_LastName = loo_JResp.StringOf("groups[i].owner.lastName")
    ls_MotifColor = loo_JResp.StringOf("groups[i].owner.motif.color")
    ls_MotifLargeIconUrl = loo_JResp.StringOf("groups[i].owner.motif.largeIconUrl")
    ls_MotifMediumIconUrl = loo_JResp.StringOf("groups[i].owner.motif.mediumIconUrl")
    ls_MotifSmallIconUrl = loo_JResp.StringOf("groups[i].owner.motif.smallIconUrl")
    ls_MotifSvgIconUrl = loo_JResp.StringOf("groups[i].owner.motif.svgIconUrl")
    ls_MySubscription = loo_JResp.StringOf("groups[i].owner.mySubscription")
    ls_Name = loo_JResp.StringOf("groups[i].owner.name")
    ls_Message = loo_JResp.StringOf("groups[i].owner.outOfOffice.message")
    ls_FullEmailPhotoUrl = loo_JResp.StringOf("groups[i].owner.photo.fullEmailPhotoUrl")
    ls_LargePhotoUrl = loo_JResp.StringOf("groups[i].owner.photo.largePhotoUrl")
    ls_MediumPhotoUrl = loo_JResp.StringOf("groups[i].owner.photo.mediumPhotoUrl")
    ls_PhotoVersionId = loo_JResp.StringOf("groups[i].owner.photo.photoVersionId")
    ls_SmallPhotoUrl = loo_JResp.StringOf("groups[i].owner.photo.smallPhotoUrl")
    ls_StandardEmailPhotoUrl = loo_JResp.StringOf("groups[i].owner.photo.standardEmailPhotoUrl")
    ls_PhotoUrl = loo_JResp.StringOf("groups[i].owner.photo.url")
    ls_Reputation = loo_JResp.StringOf("groups[i].owner.reputation")
    ls_OwnerTitle = loo_JResp.StringOf("groups[i].owner.title")
    ls_V_Type = loo_JResp.StringOf("groups[i].owner.type")
    ls_OwnerUrl = loo_JResp.StringOf("groups[i].owner.url")
    ls_UserType = loo_JResp.StringOf("groups[i].owner.userType")
    ls_PendingRequests = loo_JResp.StringOf("groups[i].pendingRequests")
    ls_PhotoFullEmailPhotoUrl = loo_JResp.StringOf("groups[i].photo.fullEmailPhotoUrl")
    ls_PhotoLargePhotoUrl = loo_JResp.StringOf("groups[i].photo.largePhotoUrl")
    ls_PhotoMediumPhotoUrl = loo_JResp.StringOf("groups[i].photo.mediumPhotoUrl")
    ls_PhotoPhotoVersionId = loo_JResp.StringOf("groups[i].photo.photoVersionId")
    ls_PhotoSmallPhotoUrl = loo_JResp.StringOf("groups[i].photo.smallPhotoUrl")
    ls_PhotoStandardEmailPhotoUrl = loo_JResp.StringOf("groups[i].photo.standardEmailPhotoUrl")
    ls_PhotoUrl = loo_JResp.StringOf("groups[i].photo.url")
    ls_V_type = loo_JResp.StringOf("groups[i].type")
    ls_Url = loo_JResp.StringOf("groups[i].url")
    ls_Visibility = loo_JResp.StringOf("groups[i].visibility")
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_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}"
    }
  ]
}