开发者社区> 问答> 正文

钉钉如何获取群会话的OpenConversationId?

钉钉如何获取群会话的OpenConversationId?

展开
收起
多麻辣哦 2024-01-23 22:36:05 30 0
2 条回答
写回答
取消 提交回答
  • 获取群会话的OpenConversationId

    POST /v1.0/im/chat/{chatId}/convertToOpenConversationId HTTP/1.1
    Host:api.dingtalk.com
    x-acs-dingtalk-access-token:String
    Content-Type:application/json
    

    群会话chatId。

    企业内部应用,可通过服务端创建群接口获取chatId参数值。
    
    企业内部应用,可通过客户端选择会话获取chatId参数值。
    

    下面是一个java的例子

    // This file is auto-generated, don't edit it. Thanks.
    package com.aliyun.sample;
    
    import com.aliyun.tea.*;
    import com.aliyun.teautil.*;
    import com.aliyun.teautil.models.*;
    import com.aliyun.dingtalkim_1_0.*;
    import com.aliyun.dingtalkim_1_0.models.*;
    import com.aliyun.teaopenapi.*;
    import com.aliyun.teaopenapi.models.*;
    
    public class Sample {
    
        /**
         * 使用 Token 初始化账号Client
         * @return Client
         * @throws Exception
         */
        public static com.aliyun.dingtalkim_1_0.Client createClient() throws Exception {
            Config config = new Config();
            config.protocol = "https";
            config.regionId = "central";
            return new com.aliyun.dingtalkim_1_0.Client(config);
        }
    
        public static void main(String[] args_) throws Exception {
            java.util.List<String> args = java.util.Arrays.asList(args_);
            com.aliyun.dingtalkim_1_0.Client client = Sample.createClient();
            ChatIdToOpenConversationIdHeaders chatIdToOpenConversationIdHeaders = new ChatIdToOpenConversationIdHeaders();
            chatIdToOpenConversationIdHeaders.xAcsDingtalkAccessToken = "<your access token>";
            try {
                client.chatIdToOpenConversationIdWithOptions("chatfaabe59a460527f5fb72fbbdfe3f061e", chatIdToOpenConversationIdHeaders, new RuntimeOptions());
            } catch (TeaException err) {
                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                    // err 中含有 code 和 message 属性,可帮助开发定位问题
                }
    
            } catch (Exception _err) {
                TeaException err = new TeaException(_err.getMessage(), _err);
                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                    // err 中含有 code 和 message 属性,可帮助开发定位问题
                }
    
            }        
        }
    }
    
    2024-01-26 17:05:09
    赞同 1 展开评论 打赏
  • 调用本接口通过chatId查询OpenConversationId。——此回答整理自钉群:钉钉开发者社区(互助群)

    2024-01-24 17:44:09
    赞同 展开评论 打赏
来源圈子
更多
收录在圈子:
+ 订阅
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载