您好,我已使用此https://docs.rocket.chat/api/rest-api/methods/channels/history通过 rest API 获取未读消息。
示例调用
( https://rcserver.rocket.chat/api/v1/im.history?roomId=ByehQjC44FwMeiLbX?&unreads=true )
( https://rcserver.rocket.chat/api/v1/im.history?roomId=ByehQjC44FwMeiLbX?&unreads=”+ true)
代码
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(Constants.CONST_SITEURL);
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("X-Auth-Token", authToken);
client.DefaultRequestHeaders.Add("X-User-Id", userRcId);
HttpResponseMessage msgHistory = client.GetAsync(Constants.CONST_CHATHISTORY + userDetail.RC_RoomID + "&count=20&unreads=true").Result;
if (msgHistory.IsSuccessStatusCode)
{
using (HttpContent content = msgHistory.Content)
{
var result = content.ReadAsStringAsync();
value = JObject.Parse(result.Result);
}
directChatWindow = JsonConvert.DeserializeObject<DirectChatWindowBO>(value.ToString());
}
我尝试了上面的链接和代码,但它不会在结果中给出任何未读属性
示例结果
{
"messages": [
{
"_id": "7e6691fc-16sdfd3-ecbfsd8-317a-4076bb307e5dfsfd-4564",
"rid": "CBsDHB7M8fsdfsdfN8G4X2BjsBDt5khnkenENacLN",
"msg": "hittti",
"ts": "2017-08-16T11:08:21.011Z",
"u": {
"_id": "CBsDHsdadsaB7M8N8G4X2Bj",
"username": "xyz",
"name": "xyz21"
},
"mentions": [],
"channels": [],
"_updatedAt": "2017-08-16T11:08:21.013Z"
},
{
"_id": "eaf75056-bcxcvxcv40c-4a68-0128-c40503289d60",
"rid": "CBsDHxcvB7M8cvxvxcvN8G4X2BjsBDt5kxcvhnkenENacLN",
"msg": "hi",
"ts": "2017-08-16T11:07:53.579Z",
"u": {
"_id": "CBsDHB7M8N8G4X2Bj",
"username": "Abc",
"name": "Abc123 "
},
"mentions": [],
"channels": [],
"_updatedAt": "2017-08-16T11:07:53.583Z"
}]
}
请帮帮我。谢谢你。