跳转到主要内容
调用本接口设置群成员之间是否可以添加好友和私聊,适用于企业内部群需要管控成员交流范围、保护信息安全等场景。

请求

基本信息
HTTP URLhttps://oapi.dingtalk.io/topapi/chat/member/friendswitch/update
HTTP MethodPOST
支持的应用类型appType-企业内部应用
权限要求permission-qyapi_chat_manage-钉钉群基础信息管理权限

查询参数

名称类型是否必填示例值描述
access_tokenString6d1bxxxx调用该接口的应用凭证,通过获取企业内部应用的access_token接口获取。

请求体

名称类型是否必填示例值描述
chatidStringchatdafe234xxxx企业会话ID。可以通过以下方式获取。 - 调用服务端创建群接口获取chatid参数值。 - 调用客户端chooseChat获取chatId参数值。
is_prohibitBooleantrue是否开启禁止开关。 - true:开启禁止开关 - false:关闭禁止开关

请求示例

curl -X POST "https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=774fdexxxx4bdd68c' \
-d 'chatid=chatdafe234sdf3sdf' \
-d 'is_prohibit=true'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update");
OapiChatMemberFriendswitchUpdateRequest req = new OapiChatMemberFriendswitchUpdateRequest();
req.setChatid("chatdafe234xxxx");
req.setIsProhibit(true);
OapiChatMemberFriendswitchUpdateResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiChatMemberFriendswitchUpdateRequest("https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update")

req.chatid="chatdafe234sdf3sdf"
req.is_prohibit=true
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_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiChatMemberFriendswitchUpdateRequest;
$req->setChatid("chatdafe234sdf3sdf");
$req->setIsProhibit("true");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update");
OapiChatMemberFriendswitchUpdateRequest req = new OapiChatMemberFriendswitchUpdateRequest();
req.Chatid = "chatdafe234sdf3sdf";
req.IsProhibit = true;
OapiChatMemberFriendswitchUpdateResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

响应

响应体

名称类型示例值描述
successBooleantrue是否设置成功。 - true:成功 - false:失败
errcodeNumber0返回码。
errmsgStringok返回码描述。
request_idString10c0wc48i6qzz请求ID。

响应体示例

{
  "success":true,
  "errcode":0,
  "errmsg":"ok",
  "request_id":"10c0wc48i6qzz"
}

错误码

若调用该接口报错,可根据错误信息在全局错误码文档中查找解决方案。
错误码(errorcode)错误码描述(errmsg)解决方案
34001无效的chatid请检查chatid是否符合要求
40036参数为空请确认必填参数是否都已经填入
400001系统错误请稍后重试