发布团队聊天消息将返回“无法找到目标地址”

时间:2020-05-17 21:46:27

标签: .net-core microsoft-graph-teams

我正在尝试向团队频道发布聊天消息,但是图形API失败,状态代码为500,错误消息为“无法找到目标地址”。

var httpRequestMessage = new HttpRequestMessage();
httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
httpRequestMessage.RequestUri = new Uri($"https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages");
httpRequestMessage.Method = HttpMethod.Post;

httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(new Message()
{
    Body = new ItemBody()
    {
        ContentType = BodyType.Text,
        Content = message
    }
}), Encoding.UTF8, "application/json");

var task = Task.Run(() => Client.SendAsync(httpRequestMessage));

0 个答案:

没有答案