> ## 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.

# Memperbarui kontak eksternal

> Panggil API ini untuk memperbarui kontak eksternal organisasi di DingTalk. Panduan parameter permintaan dan struktur respons bagi pengembang aplikasi internal.

Panggil API ini untuk memperbarui kontak eksternal organisasi Anda.

## Permintaan

| **Informasi dasar**         |                                                                                                      |
| --------------------------- | ---------------------------------------------------------------------------------------------------- |
| URL HTTP                    | [https://api.dingtalk.io/topapi/extcontact/update](https://api.dingtalk.io/topapi/extcontact/update) |
| Metode HTTP                 | POST                                                                                                 |
| Tipe aplikasi yang didukung | appType-Internal app                                                                                 |
| Izin yang diperlukan        | permission-qyapi\_ext\_write-Izin tulis untuk kontak eksternal                                       |

### Parameter query

| Nama          | Tipe   | Wajib | Contoh   | Deskripsi                                                                                                                                                                           |
| ------------- | ------ | ----- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Ya    | 6d1bxxxx | Kredensial aplikasi yang digunakan untuk memanggil API ini. Dapatkan melalui API untuk memperoleh [access\_token dari aplikasi internal](/id/open/development/obtain-orgapp-token). |

### Isi permintaan

| Nama               | Tipe           | Wajib | Contoh               | Deskripsi                                                                                                                                                                                                                                                                                                                                    |
| ------------------ | -------------- | ----- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| contact            | OpenExtContact | Ya    |                      | Informasi kontak eksternal.                                                                                                                                                                                                                                                                                                                  |
| title              | String         | Tidak | Development Engineer | Jabatan.                                                                                                                                                                                                                                                                                                                                     |
| label\_ids         | Number\[]      | Ya    | \[1,2,3]             | Daftar tag. Panggil API [Dapatkan daftar kontak eksternal](/id/open/development/obtain-the-external-contact-list) untuk menanyakan informasi tag.  Lihat [Cara menyesuaikan grup tag untuk organisasi](https://tms.dingtalk.io/markets/dingtalk/biaoqianzu) untuk menambahkan tag kustom.  Maksimal 20 labelIds dapat dikirim per panggilan. |
| share\_dept\_ids   | Number\[]      | Tidak | \[420606536]         | ID departemen yang akan dibagikan. Panggil API [Dapatkan daftar ID subdepartemen](/id/open/development/obtain-the-list-of-sub-department-ids) untuk memperolehnya.  Maksimal 20 ID departemen dapat dikirim per panggilan.                                                                                                                   |
| address            | String         | Tidak | Beijing              | Alamat.                                                                                                                                                                                                                                                                                                                                      |
| remark             | String         | Tidak | Technical Lead       | Alias.                                                                                                                                                                                                                                                                                                                                       |
| follower\_user\_id | String         | Ya    | 023420013645         | userId pemilik.                                                                                                                                                                                                                                                                                                                              |
| name               | String         | Ya    | Zhang xx             | Nama kontak eksternal.                                                                                                                                                                                                                                                                                                                       |
| user\_id           | String         | Ya    | 123420013632         | userId kontak eksternal. Panggil API [Dapatkan daftar kontak eksternal](/id/open/development/obtain-the-external-contact-list) untuk memperolehnya.                                                                                                                                                                                          |
| company\_name      | String         | Tidak | DingTalk             | Nama organisasi kontak eksternal.                                                                                                                                                                                                                                                                                                            |
| share\_user\_ids   | String\[]      | Tidak | \["023420013644"]    | Daftar userid karyawan yang akan dibagikan.  Maksimal 20 labelIds dapat dikirim per panggilan.                                                                                                                                                                                                                                               |

### Contoh permintaan

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/extcontact/update" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=34ddexxxx6c95' \
-d 'contact=null'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/extcontact/update");
OapiExtcontactUpdateRequest req = new OapiExtcontactUpdateRequest();
OapiExtcontactUpdateRequest.OpenExtContact contact = new OapiExtcontactUpdateRequest.OpenExtContact();
contact.setTitle("Development Engineer");
contact.setLabelIds(Arrays.asList(1L,2L,3L));
contact.setShareDeptIds(Arrays.asList(420606536
L));
contact.setAddress("Beijing");
contact.setRemark("Technical Lead");
contact.setFollowerUserId("023420013645");
contact.setName("Zhang xx");
contact.setUserId("123420013632");
contact.setCompanyName("DingTalk");
contact.setShareUserIds(Arrays.asList("user123"));
req.setContact(contact);
OapiExtcontactUpdateResponse 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.OapiExtcontactUpdateRequest("https://api.dingtalk.io/topapi/extcontact/update")

req.contact=""
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 OapiExtcontactUpdateRequest;
$contact = new OpenExtContact;
$contact->title="Development Engineer";
$contact->label_ids="[1,2,3]";
$contact->share_dept_ids="[1,2,3]";
$contact->address="Address details";
$contact->remark="Remark details";
$contact->follower_user_id="023420013645";
$contact->name="John";
$contact->user_id="123420013632";
$contact->company_name="DingTalk";
$contact->share_user_ids="[\"023420013644\"]";
$req->setContact($contact);
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/extcontact/update");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/extcontact/update");
OapiExtcontactUpdateRequest req = new OapiExtcontactUpdateRequest();
OapiExtcontactUpdateRequest.OpenExtContactDomain obj1 = new OapiExtcontactUpdateRequest.OpenExtContactDomain();
obj1.Title = "Development Engineer";
obj1.LabelIds = new long[] { 1,2,3 };
obj1.ShareDeptIds = new long[] { 1,2,3 };
obj1.Address = "Address details";
obj1.Remark = "Remark details";
obj1.FollowerUserId = "023420013645";
obj1.Name = "John";
obj1.UserId = "123420013632";
obj1.CompanyName = "DingTalk";
obj1.ShareUserIds = ""023420013644"";
req.Contact_ = obj1;
OapiExtcontactUpdateResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Respons

### Isi respons

| Nama        | Tipe   | Contoh       | Deskripsi      |
| ----------- | ------ | ------------ | -------------- |
| errcode     | Number | 0            | Kode hasil.    |
| request\_id | String | 8n3mksu5hqzy | ID permintaan. |

### Contoh isi respons

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "request_id": "8n3mksu5hqzy""
}
```

### Kode error

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

| Kode error (errcode) | Pesan error (errmsg)                              | Solusi                                                                  |
| -------------------- | ------------------------------------------------- | ----------------------------------------------------------------------- |
| 33009                | Invalid tokenGrantType                            | Periksa apakah access\_token sudah benar.                               |
| 40036                | Empty parameter                                   | Periksa apakah semua parameter wajib sudah diisi.                       |
| 40003                | Invalid userId                                    | Periksa apakah userId sudah benar.                                      |
| 60112                | Invalid user name                                 | Periksa apakah nama pengguna sudah benar.                               |
| 60121                | The corresponding user is not found               | Periksa apakah informasi pengguna sudah benar.                          |
| 60204                | A label is required for the external contact      | Isi label\_ids untuk kontak eksternal.                                  |
| 43007                | Permission required                               | Periksa apakah access\_token memiliki izin untuk melakukan operasi ini. |
| 60103                | Invalid mobile number                             | Periksa apakah nomor ponsel sudah benar.                                |
| 60200                | The external contact already exists               | Periksa apakah informasi kontak eksternal sudah benar.                  |
| 60203                | The number of external contacts exceeds the limit | Hapus beberapa kontak eksternal.                                        |
| -1                   | System busy                                       | Coba lagi nanti.                                                        |
