【问题标题】:Can't createChatThread() with Preview 4 azure-sdk-for-js无法使用 Preview 4 azure-sdk-for-js 创建ChatThread()
【发布时间】:2021-06-06 16:23:30
【问题描述】:

示例代码 sn -p @ https://github.com/Azure/azure-sdk-for-js/tree/%40azure/communication-identity_1.0.0-beta.4/sdk/communication/communication-chat 无法编译。

import { ChatClient, ChatThreadClient } from '@azure/communication-chat';
import { AzureCommunicationTokenCredential } from '@azure/communication-common';

let createChatThreadRequest =
{
    topic: 'Preparation for London conference',
    participants:
        [
            {
                user: { communicationUserId: '<USER_ID_FOR_JACK>' },
                displayName: 'Jack'
            },
            {
                user: { communicationUserId: '<USER_ID_FOR_GEETA>' },
                displayName: 'Geeta'
            }
        ]
};

let createChatThreadResponse = await chatClient.createChatThread(createChatThreadRequest);
let threadId = createChatThreadResponse.chatThread.id;

我的 package.json:

"@azure/communication-identity": "1.0.0-beta.4",
"@azure/communication-calling": "1.0.0-beta.6",
"@azure/communication-chat": "1.0.0-beta.4",
"@azure/communication-common": "1.0.0-beta.5",
"@azure/communication-signaling": "1.0.0-beta.2",

最新尝试:

createChatThreadRequest:
{
    "topic": "Ghost Frog",
    "participants": [
        {
            "user": {
                "communicationUserId": "ey...Ug"
            },
            "displayName": "frog"
        }
    ]
}

POST 错误 400 https://########.communication.azure.com/chat/threads?api-version=2020-11-01-preview3

RestError: {"error":{"code":"BadRequest","message":"发生了一个或多个验证错误。","details":[{"message":"为 Id 提供的值是无效。","target":"Participants[0].Id"}]}}

错误消息正在寻找名为“Id”的属性。该规范不需要 ID。参数。

【问题讨论】:

    标签: javascript azure azure-communication-services


    【解决方案1】:

    很抱歉您遇到了问题,感谢您与我们联系!

    我们团队中的某个人已经测试了您的代码 sn-p 和 SDK 版本并进行了编译。你能指定你看到的错误代码吗?这将有助于我们更好地理解问题。谢谢!

    【讨论】:

    • 感谢您如此迅速地解决这个问题。我很尴尬地承认,重启解决了我的问题。我想我的解决方案配置可能存在一些问题。无论如何,这段代码现在肯定可以编译。在你有机会阅读我的评论后,我会删除这个问题。
    • 很高兴您知道了 :) 如果您遇到任何其他问题,请告诉我们!
    • 我还是死在水里:( 有人知道使用最新版本的 javascript sdk 的任何工作示例代码吗?这段代码可以编译,但我使用错误或 api 不工作.
    【解决方案2】:

    假设您使用的是版本1.0.0-beta.4,我可以验证您拥有的代码 sn-p 是否正确。

    在最新版本的 JS SDK 1.0.0-beta.5 中,user 属性实际上已重命名为 id,但之前的版本仍应按预期工作。

    您能否验证最新版本是否适合您?如果提供了无效的communicationUserId,也会出现您看到的错误。

    鉴于您当前的版本和代码,如果问题仍然存在,我们愿意进行调查。

    我们尝试在公开预览期间使这些文档保持最新,但如果您遇到问题,请告诉我们:

    https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/communication/communication-chat

    https://docs.microsoft.com/en-us/azure/communication-services/quickstarts/chat/get-started?pivots=programming-language-javascript

    【讨论】:

      猜你喜欢
      • 2021-06-19
      • 2020-05-03
      • 2016-10-31
      • 1970-01-01
      • 2015-04-15
      • 1970-01-01
      • 2020-02-25
      • 2021-04-20
      • 1970-01-01
      相关资源
      最近更新 更多