# 使用统一 ID 获取用户 ID
使用统一 ID 获取用户 ID信息。<br>

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/user/v1/union_id/batch_get/list?union_ids=on_94a1ee5551019f18cd73d9f111898cf2&union_ids=on_42f2ef9d07319a4d96fffd7ef5cbfc79
HTTP Method | GET
字段权限要求<br>**接口返回的部分字段受权限控制，开启字段权限才可获取对应字段数据；如无需获取这些字段，则无需开启。**<br>根据要获取的字段开启相应权限 | 获取用户 user ID

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | 是 | **固定值**："application/json; charset=utf-8"

### 查询参数
参数 | 类型 | 必须 | 说明
-- | -- | -- | --
union_ids |string | 是 | 要查询的用户union_id，最多100条
## 响应
### 响应体
参数 | 说明
-- | --
code | 返回码，非 0 表示失败
msg | 对返回码的文本描述
data | 返回内容
&emsp;∟user_infos | 用户信息
&emsp;&emsp;∟open_id | 用户的 open_id
&emsp;&emsp;∟user_id | 用户的 user_id，获取employee_id权限后返回
### 响应体示例
```json
{
    "code": 0,
    "msg": "",
    "data": {
        "user_infos": {
            "on_7dba11ff38a2119f89349876b12af65c": {
                "user_id": "b6e596g8",
                "open_id": "ou_ef74363752064ca799c2bb7b6bdca9f4"
            },
            "on_c132837f686587dd494aa54f5f65b552": {
                "user_id": "384cf662",
                "open_id": "ou_47e071d2656df0df08a49d87e0c7f518"
            },
            "on_d12d180970dcc5e89f26929745166fb3": {
                "user_id": "3cc7eaf6",
                "open_id": "ou_c1ba95fa08f067545a99c8dba5bf588e"
            }
        }
    }
}
```

### 调用代码示例
#### Python
```python
# Install the Python Requests library:
# `pip install requests`

import requests

def send_request():
    # send HTTP 请求
    # GET https://open.feishu.cn/open-apis/user/v1/union_id/batch_get/list
    try:
        response = requests.get(
            url="https://open.feishu.cn/open-apis/user/v1/union_id/batch_get/list",
            params={
                "union_ids": "on_94a1ee5551019f18cd73d9f111898cf2,on_42f2ef9d07319a4d96fffd7ef5cbfc79",
            },
            headers={
                "Authorization": "Bearer {TOKEN}",
                "Cookie": "swp_csrf_token=90f04ead-f72c-4991-bcf4-dc51ed3cb366; t_beda37=7ca645c45c4c0820f83f9bfa0a5ba2f2a00eb0937e2bbe5ca36f59ab12cf7c79",
            },
        )
        print('Response HTTP Status Code: {status_code}'.format(
            status_code=response.status_code))
        print('Response HTTP Response Body: {content}'.format(
            content=response.content))
    except requests.exceptions.RequestException:
        print('HTTP Request failed')

```
#### Go
```golang
package main

import (
	"fmt"
	"io"
	"net/http"
)

func sendSendHttp() {
	// send HTTP 请求 (GET https://open.feishu.cn/open-apis/user/v1/union_id/batch_get/list?union_ids=on_94a1ee5551019f18cd73d9f111898cf2&union_ids=on_42f2ef9d07319a4d96fffd7ef5cbfc79)

// Create client
	client := &http.Client{}

// Create request
	req, err := http.NewRequest("GET", "https://open.feishu.cn/open-apis/user/v1/union_id/batch_get/list?union_ids=on_94a1ee5551019f18cd73d9f111898cf2&union_ids=on_42f2ef9d07319a4d96fffd7ef5cbfc79", nil)

// Headers
	req.Header.Add("Authorization", "Bearer {TOKEN}")
	req.Header.Add("Cookie", "swp_csrf_token=90f04ead-f72c-4991-bcf4-dc51ed3cb366; t_beda37=7ca645c45c4c0820f83f9bfa0a5ba2f2a00eb0937e2bbe5ca36f59ab12cf7c79")

parseFormErr := req.ParseForm()
	if parseFormErr != nil {
	  fmt.Println(parseFormErr)    
	}

// Fetch Request
	resp, err := client.Do(req)

if err != nil {
		fmt.Println("Failure : ", err)
	}

// Read Response Body
	respBody, _ := io.ReadAll(resp.Body)

// Display Results
	fmt.Println("response Status : ", resp.Status)
	fmt.Println("response Headers : ", resp.Header)
	fmt.Println("response Body : ", string(respBody))
}
```
#### Java
```java
import java.io.IOException;
import org.apache.http.client.fluent.*;

public class SendRequest
{
  public static void main(String[] args) {
    sendRequest();
  }

private static void sendRequest() {

// send HTTP 请求 (GET )

try {

// Create request
      Content content = Request.Get("https://open.feishu.cn/open-apis/user/v1/union_id/batch_get/list?union_ids=on_94a1ee5551019f18cd73d9f111898cf2&union_ids=on_42f2ef9d07319a4d96fffd7ef5cbfc79")

// Add headers
      .addHeader("Authorization", "Bearer {TOKEN}")
      .addHeader("Cookie", "swp_csrf_token=90f04ead-f72c-4991-bcf4-dc51ed3cb366; t_beda37=7ca645c45c4c0820f83f9bfa0a5ba2f2a00eb0937e2bbe5ca36f59ab12cf7c79")

// Fetch request and return content
      .execute().returnContent();

// Print content
      System.out.println(content);
    }
    catch (IOException e) { System.out.println(e); }
  }
}

```

### 错误码

具体可参考：[服务端错误码说明](https://open.feishu.cn/document/ukTMukTMukTM/ugjM14COyUjL4ITN)