Hello I have used this https://docs.rocket.chat/api/rest-api/methods/channels/history for get unread message via rest API.
Example Call
(https://rcserver.rocket.chat/api/v1/im.history?roomId=ByehQjC44FwMeiLbX?&unreads=true)
(https://rcserver.rocket.chat/api/v1/im.history?roomId=ByehQjC44FwMeiLbX?&unreads=”+ true)
Code
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());
}
I have try to above link and code but it will not give any unread property in result
Example Result
{
"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"
}]
}
Please help me out. Thank You.