> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Mendapatkan detail peran

> Panggil API ini untuk mendapatkan detail peran tertentu berdasarkan ID peran di DingTalk, termasuk nama peran dan grup peran yang menaunginya guna mengelola kontak organisasi.

Panggil API ini untuk mendapatkan detail peran tertentu berdasarkan ID peran.

## Permintaan

| **Informasi dasar**         |                                                                                            |
| --------------------------- | ------------------------------------------------------------------------------------------ |
| URL HTTP                    | [https://api.dingtalk.io/topapi/role/getrole](https://api.dingtalk.io/topapi/role/getrole) |
| Metode HTTP                 | POST                                                                                       |
| Tipe aplikasi yang didukung | appType-Aplikasi internal appType-Aplikasi perusahaan pihak ketiga                         |
| Izin yang diperlukan        | permission-qyapi\_get\_department\_member-Izin baca untuk pengguna departemen Kontak       |

### Parameter query

| Nama          | Tipe   | Wajib | Contoh   | Deskripsi                                                                                                                                                                                                                                                                                                                            |
| ------------- | ------ | ----- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| access\_token | String | Ya    | bE74xxxx | Kredensial aplikasi yang digunakan untuk memanggil API ini.   - Untuk aplikasi internal, dapatkan melalui API untuk mendapatkan [access\_token aplikasi internal](/id/open/development/obtain-orgapp-token). - Untuk aplikasi perusahaan pihak ketiga, dapatkan melalui API untuk mendapatkan access\_token perusahaan pihak ketiga. |

### Isi permintaan

| Nama   | Tipe   | Wajib | Contoh     | Deskripsi                                                                                                                                        |
| ------ | ------ | ----- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| roleId | Number | Ya    | 1581321999 | ID peran. Untuk mendapatkan nilai parameter id, panggil API [Mendapatkan daftar peran](/id/open/development/obtains-a-list-of-enterprise-roles). |

### Contoh permintaan

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/role/getrole" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=2c9ecxxxx4210' \
-d 'roleId=1001'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrole");
OapiRoleGetroleRequest req = new OapiRoleGetroleRequest();
req.setRoleId(1507113578L);
OapiRoleGetroleResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiRoleGetroleRequest("https://api.dingtalk.io/topapi/role/getrole")

req.roleId=1001
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiRoleGetroleRequest;
$req->setRoleId("1001");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/getrole");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrole");
OapiRoleGetroleRequest req = new OapiRoleGetroleRequest();
req.RoleId = 1001L;
OapiRoleGetroleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Respons

### Isi respons

| Nama        | Tipe     | Contoh       | Deskripsi                                   |
| ----------- | -------- | ------------ | ------------------------------------------- |
| role        | OpenRole |              | Informasi peran.                            |
| name        | String   | Owner        | Nama peran.                                 |
| groupId     | Number   | 1507113577   | ID grup peran yang menaungi peran tersebut. |
| errcode     | Number   | 0            | Kode pengembalian.                          |
| errmsg      | String   | ok           | Deskripsi kode pengembalian.                |
| request\_id | String   | 4cmr6app8ujf | ID permintaan.                              |

### Contoh respons

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "role":{
    "groupId":1507113577,
    "name":"Owner"
  },
  "request_id":"4cmr6app8ujf"
}
```

### Kode error

Jika terjadi error saat Anda memanggil API ini, temukan solusinya di dokumen [Kode error global](/id/open/development/server-api-error-codes-1) berdasarkan pesan error.

| Kode error (errcode) | Pesan error (errmsg)          | Solusi                                                |
| -------------------- | ----------------------------- | ----------------------------------------------------- |
| 33011                | Invalid roleId                | Pastikan roleId sudah benar.                          |
| 43007                | Operation permission required | Pastikan access\_token memiliki izin yang diperlukan. |
| 400001               | System error                  | Coba lagi nanti.                                      |
