跳转到主要内容
调用本接口获取群设置和成员信息。,适用于群管理员查看群设置和成员信息、进行群管理决策等场景。

请求

基本信息
HTTP URLhttps://oapi.dingtalk.io/chat/get
HTTP MethodGET
支持的应用类型appType-企业内部应用
权限要求permission-qyapi_chat_read-钉钉群基础信息读权限

查询参数

名称类型是否必填示例值描述
access_tokenString6d1bxxxx调用该接口的应用凭证,通过获取企业内部应用的access_token接口获取。
chatidStringchate39f540dxxxx群会话的ID。 - 仅支持通过调用服务端创建群会话接口获取的chatid参数值。 - 不支持通过调用前端JSAPI获取的chatid。

请求示例

curl -X GET "https://oapi.dingtalk.io/chat/get" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=0d7e495xxxxa3f694fd6e' \
-d 'chatid=chatid'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/chat/get");
OapiChatGetRequest req = new OapiChatGetRequest();
req.setChatid("chate39f540dxxxx");
req.setHttpMethod("GET");
OapiChatGetResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiChatGetRequest("https://oapi.dingtalk.io/chat/get")

req.chatid="chatid"
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
PHP
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_GET , DingTalkConstant::$FORMAT_JSON);
$req = new OapiChatGetRequest;
$req->setChatid("chatid");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/chat/get");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/chat/get");
OapiChatGetRequest req = new OapiChatGetRequest();
req.Chatid = "chatid";
req.SetHttpMethod("GET");
OapiChatGetResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

响应

响应体

名称类型示例值描述
errcodeNumber0返回码。
errmsgStringok返回码描述。
chat_infoChatInfo群会话信息。
nameString全员群群名称。
ownerStringmanager4220群主的userId。
useridlistString[][“user123”,“manager4220”]群成员的userId列表。
conversationTagNumber2会话类型: - 2:企业群。
chatBannedTypeNumber0是否开启群禁言: - 0(默认):不禁言 - 1:全员禁言
searchableNumber0群是否可以被搜索: - 0(默认):不可搜索 - 1:可搜索
validationTypeNumber0入群是否需要验证 - 0(默认):不验证 - 1:入群验证
mentionAllAuthorityNumber0@all 使用范围: - 0(默认):所有人可使用 - 1:仅群主可@all
managementTypeNumber0群管理类型: - 0(默认):所有人可管理 - 1:仅群主可管理
showHistoryTypeNumber0新成员是否可查看100条历史消息: - 1:可查看 - 0:不可查看 如果不传值,代表不可查看。
iconString@lADPDfJ6Q7LLejDNAljNAlg群头像的mediaID。
statusNumber1状态。 - 1:正常 - 2:已解散

响应体示例

{
  "errcode":0,
  "errmsg":"ok",
  "chat_info":{
    "owner":"manager4220",
    "mentionAllAuthority":0,
    "showHistoryType":0,
    "chatid":"chate39f540dxxxx",
    "conversationTag":2,
    "validationType":0,
    "useridlist":[
      "user123",
      "manager4220"
    ],
    "icon":"@lADPDfJ6Q7LLejDNAljNAlg",
    "name":"全员群",
    "searchable":0,
    "chatBannedType":0,
    "managementType":0
  }
}

错误码

若调用该接口报错,可根据错误信息在全局错误码文档中查找解决方案。
错误码(errorcode)错误码描述(errmsg)解决方案
43007没有调用权限请确认是否是当前应用生成access_token。
49000需要参数chatid请填入chatid
40001无效的token请确认access_token是否正确
70001企业不存在请确认参数是否正确
40016无效的chatid请确认access_token和chatid来自同一个企业
-1系统繁忙请稍后重试