> For the complete documentation index, see [llms.txt](https://bayun.gitbook.io/bayuncoresdk-android/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bayun.gitbook.io/bayuncoresdk-android/6.-groups/6.5-get-group-by-id.md).

# 7.5 Get Group By Id

The `getGroupById` returns details of a group. Details include groupId, name, type, groupMembers. Any existing member of the group can retrieve details of the group, including the list of all the group members.

**Method parameters :**

* **groupId** : Group Id of the Group.
* **success** : Success block to be executed after group details are successfully retrieved.
* **failure** : Failure block to be executed if group details could not be retrieved, returns `BayunError`.

{% tabs %}
{% tab title="Java" %}

```java
String groupId = "<groupId>";
Group groupDetails;

// Callbacks to get group info by its id
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        Log.d(TAG, "Get group by id call successful.");
        groupDetails = (Group)message.getData().getSerializable("BayunGetGroup");
        
        Log.d(TAG, "group id: " + groupDetails.groupId);
        Log.d(TAG, "group name: " + groupDetails.groupName);
        Log.d(TAG, "group type: " + groupDetails.groupType);
        ArrayList<GroupMember> groupMembers = (ArrayList<GroupMember>)groupDetails.groupMembers;
        
        for (GroupMember member: groupMembers) {
            Log.d(TAG, "companyEmployeeId: " + member.companyEmployeeId));
            Log.d(TAG, "companyId: " + member.companyId);
            Log.d(TAG, "companyName: " + member.companyName));
        }
        return false;
    }
};

Handler.Callback failure = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        String error = message.getData().getString("BayunError", "");
        Log.d(TAG, "Error getting group.");
        return false;
    }
};

bayunCore.getGroupById(groupId, success, failure);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
var groupId = "<groupId>"
var groupDetails: Group

// Callbacks to get group info by its id
val success = Handler.Callback {
    Log.d(TAG, "Get group by id call successful.")
    groupDetails = it.data.getSerializable("BayunGetGroup") as Group
    Log.d(TAG, "group id: " + groupDetails.groupId)
    Log.d(TAG, "group name: " + groupDetails.groupName)
    Log.d(TAG, "group type: "+ groupDetails.groupType)
    
    val groupMembers = groupDetails.groupMembers
    as ArrayList<GroupMember>
    
    for (member in groupMembers) {
        Log.d(TAG, "companyEmployeeId: " + member.companyEmployeeId)
        Log.d(TAG, "companyId: " + member.companyId)
        Log.d(TAG, "companyName: " + member.companyName)
    }
    false
}

val failure = Handler.Callback {
    val error = it.data.getString("BayunError", "")
    Log.d(TAG, "Error getting group.")
    false
}

bayunCore.getGroupById(groupId, success, failure)
```

{% endtab %}
{% endtabs %}
