I'm trying to get a simple count of unread messages in a folder, but I'd like to just get a count without having to retrieve any of the message detail.
The closest I've got is something like this:
https://graph.microsoft.com/v1.0/users/{user}/mailFolders/Inbox/messages?$filter=isRead ne true&$count=true&$select=id&top=1
Notice that I'm including $select=id here, but I don't really want that - I'm just looking for a simple count.
Something like this is closer to what I need:
https://graph.microsoft.com/v1.0/users/{user}/mailFolders/Inbox
This gives some basic folder information for that folder, including the unreadItemCount.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('{user}')/mailFolders/$entity",
"id": "AAMkADQwNDkzY2MwLWRkODMtNDdkYS05MjNmLWI0YTA4OTNlN2U1ZgAuAAAAAABpELO9F64CS6YLKzHVeiwoAQDXOQANV1mvRZBdzyuZRD-5AAAAAAEMAAA=",
"displayName": "Inbox",
"parentFolderId": "AAMkADQwNDkzY2MwLWRkODMtNDdkYS05MjNmLWI0YTA4OTNlN2U1ZgAuAAAAAABpELO9F64CS6YLKzHVeiwoAQDXOQANV1mvRZBdzyuZRG-5AAAAAAEIAAA=",
"childFolderCount": 0,
"unreadItemCount": 1,
"totalItemCount": 2
}
To get only the unread item count of your Inbox (or any other folder, for that matter), you can use this:
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox?$select=unreadItemCount
This will return:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('{user}')/mailFolders/$entity",
"id": "AAMkADQwNDkzY2MwLWRkODMtNDdkYS05MjNmLWI0YTA4OTNlN2U1ZgAuAAAAAABpELO9F64CS6YLKzHVeiwoAQDXOQANV1mvRZBdzyuZRD-5AAAAAAEMAAA=",
"unreadItemCount": 19
}
Related
I have a message extension app for MS TEAMS. I am going to use https://graph.microsoft.com/v1.0/groups/{group-id-for-teams}/members for getting "members". Where can I get group-id-for-teams? ChannelAccount data looks like
"conversationAccount": {
"isGroup": true,
"conversationType": "channel",
"id": "34:v7g123e0ee5a4502943cfcf24f12123c#thread.skype",
"name": null,
"aadObjectId": null,
"role": null,
"tenantId": "11111111-1111-1111-1111-111111111111"
There is some Id but it is not group-id-for-teams.
You can query https://graph.microsoft.com/v1.0/groups to get all groups. You can search for you group and get the id.
For teams you can query https://graph.microsoft.com/v1.0/me/joinedTeams to get all teams which you are part. There is no api for all teams i guess.
You can right away go to Graph explorer(https://developer.microsoft.com/en-us/graph/graph-explorer), sign in and run those query and see result.
Using MS Graph API /beta endpoint to figure out if the list has been updated/changed.
Used the following query first:
https://graph.microsoft.com/beta/sites/xxxxx.sharepoint.com:/sites/xxxxx?$expand=lists(select=id, name, system, lastModifiedDateTime)
And did get the following date:
"lastModifiedDateTime": "2018-10-08T10:23:37Z",
But when going against the items and see the dates on the latest item with the following query:
https://graph.microsoft.com/beta/sites/xxxxx.sharepoint.com,92af4fbc-04bc-46d8-9c78-f63832fbf48a,1b59d85a-41bd-4498-a64c-17bd13069d90/lists/b9c39323-076a-4ae7-942b-1d0060a6b352/items
you can see the dates:
"createdDateTime": "2018-10-08T10:23:37Z"
"lastModifiedDateTime": "2018-10-08T10:29:14Z",
You can see that lastModifiedDateTime property on the list looks like actually lastCreatedDateTime?
Best Regards,
Kim
edit:
First graph request gets the SitePages list and its lastModifiedDateTime:
{
"id": "b9c39323-076a-4ae7-942b-1d0060a6b352",
"lastModifiedDateTime": "2018-10-08T10:23:37Z",
"name": "SitePages",
"system": {}
},
But if we then look at the items of the list, we can see that it has an item with a higher lastModifiedDateTime (second graph request):
"createdDateTime": "2018-10-08T10:23:37Z",
"eTag": "\"27e03a98-9321-4586-8ef1-0b5323c26730,6\"",
"id": "8",
"lastModifiedDateTime": "2018-10-08T10:29:14Z",
We can also see that the createdDateTime of the listitem is the same as the list lastModifiedDateTime. Looks like a bug in the api to mee. The date in the first request should be "2018-10-08T10:29:14Z". Dont you agree?
As your description, I assume you want to know why the LastModifyDateTime is different.
Base on my test, your first link is to get the lastModifyDateTime of the special site,
but your second link is about the items of the b9c39....
We can use the MS Graph Explore to check whether this two site has some differences.
Indeed, it appears to be a bug, for List resource lastModifiedDateTime property returns invalid value, it seems to be mapped to the last list item date and time when the item was created (ListItem.createdDateTime)
It could also be confirmed as a bug using the following endpoints (in both examples a valid lastModifiedDateTime value is returned):
https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/drive/root?select=lastModifiedDateTime
https://tenant.sharepoint.com/_api/web/lists/getbyid({list-id})?$select=LastItemModifiedDate
Meanwhile as a workaround the following solution could be considered to enumerate site lists:
https://graph.microsoft.com/beta/sites/{site-id}/drives?expand=root(select=lastModifiedDateTime)
where root/lastModifiedDateTime returns a valid value
Limitation: Only returns document libraries
I am using https://graph.microsoft.com/v1.0/me/messages?$filter=isRead eq false in Microsoft Graph Explorer to return a list of my unread emails. My goal is to have a simple HUD on my website that shows a notification to any logged-in user how many unread messages they have waiting for them in Outlook.
The problem is this returns all unread emails in my Junk Email folder in addition to my legitimate unread emails. I would like to filter out Junk Email, but graph doesn't give me a way to systemically accomplish this for all users.
All emails have a parentFolderID, and Graph says the email in my Junk email folder has "parentFolderId": "AQMkAGFjOGFkNWM2LTcxMjQtND...". This means I could filter out my own Junk Email, but that doesn't help the rest of my users since they would each have a unique parentFolderID for their Junk Email.
I could create a rule for myself that marks Junk Email as read, but I can't expect my users to do something like that.
Any thoughts on how I can filter out Junk Email for all users?
I do not think a single query to the Graph API will solve this problem, but you can do multiple calls with a little bit of logic to solve this.
List all mailFolders
https://graph.microsoft.com/v1.0/me/mailFolders
Find the 'Junk Email' folder
var json = `
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/mailFolders",
"value": [
{
"id": "AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OAAuAAAAAAAiQ8W967B7TKBjgx9rVEURAQAiIsqMbYjsT5e-T7KzowPTAAAAAAEkAAA=",
"displayName": "Junk Email",
"parentFolderId": "AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OAAuAAAAAAAiQ8W967B7TKBjgx9rVEURAQAiIsqMbYjsT5e-T7KzowPTAAAAAAEIAAA=",
"childFolderCount": 0,
"unreadItemCount": 0,
"totalItemCount": 0
}
]
}`
var obj = JSON.parse(json)
for(var folder in obj.value)
{
if (obj.value[folder].displayName == 'Junk Email')
{
document.write(obj.value[folder].id)
break
}
}
Filter out messages from that folder as you described, uniquely per user.
To get a count of unread mail from ONLY my inbox, I ended up using:
https://graph.microsoft.com/v1.0/me/mailFolders?$filter=displayName eq 'Inbox'
which returns:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('ed313cf6-f369-45c6-94b2-48bbb3589788')/mailFolders",
"value": [
{
"id": "AAMkAGFjOGFkNWM2LTcxMjQtNDQ4My1iNjBlLTVhZmNiNTA3ZTcwNQAuAAAAAAAcAJPfHQ_aQputXsbIt-bZAQC5oqQhrW6CRI4cZpo9l5YaAA7BDDZpAAA=",
"displayName": "Inbox",
"parentFolderId": "AAMkAGFjOGFkNWM2LTcxMjQtNDQ4My1iNjBlLTVhZmNiNTA3ZTcwNQAuAAAAAAAcAJPfHQ_aQputXsbIt-bZAQC5oqQhrW6CRI4cZpo9l5YaAA7BDDZmAAA=",
"childFolderCount": 14,
"unreadItemCount": 1,
"totalItemCount": 25
}
]
}
The data I'm after is in "unreadItemCount". Thanks for Shawn Tabrizi for setting me on the correct path with /me/mailFolders.
Please note that you currently cannot filter /me/messages by parentFolderId, so you would need to run custom filtering code like Shawn Tabrizi had suggested if you want to get any mail content from /me/messages.
{
"error": {
"code": "ErrorInvalidProperty",
"message": "The property 'ParentFolderId' does not support filtering.",
"innerError": {
"request-id": "526bafdd-d8ac-47f2-be1f-656b3b93da35",
"date": "2017-10-11T15:45:33"
}
}
}
You can run two separate queries to get all new emails in the inbox folder and their content data.
First run:
https://graph.microsoft.com/v1.0/me/mailFolders?$filter=displayName eq 'Inbox'
to get details on the Inbox folder only.
$filter=displayName eq 'Inbox' filters folders with displayName equal to (eq) 'Inbox'
This returns:
`{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('9285d2c9-f210-45e1-b78e-d74ba3d5e186')/mailFolders",
"value": [
{
"id": "AAMkADRlM2I0YmM5LWI2MTUtNDgzZC04N2M0LWJmMWU1MTFjMDBiYwAuAAAAAAB1tij3RiDhRab9QpP_GQhpAQCTj9cyjezTSYJYfMfg3p5fAAAAAAEMAAA=",
"displayName": "Inbox",
"parentFolderId": "AAMkADRlM2I0YmM5LWI2MTUtNDgzZC04N2M0LWJmMWU1MTFjMDBiYwAuAAAAAAB1tij3RiDhRab9QpP_GQhpAQCTj9cyjezTSYJYfMfg3p5fAAAAAAEIAAA=",
"childFolderCount": 0,
"unreadItemCount": 1,
"totalItemCount": 0
}
]
}`
To get the content data you need the id value to form part of the second query.
Add &$count=true to the end to get the count of unread emails in Inbox:
Second query:
https://graph.microsoft.com/v1.0/me/mailFolders/{ Inbox id goes here }/messages?$filter=isRead eq false&$count=true
This filters the unread (isRead eq false) from the Inbox folder and returns something like:
`{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('9285d2c9-f210-45e1-b78e-d74ba3d5e186')/mailFolders('AAMkADRlM2I0YmM5LWI2MTUtNDgzZC04N2M0LWJmMWU1MTFjMDBiYwAuAAAAAAB1tij3RiDhRab9QpP_GQhpAQCTj9cyjezTSYJYfMfg3p5fAAAAAAEMAAA%3D')/messages",
"#odata.count": 1,
"value": [
{
"#odata.etag": "W/\"CQAAABYAAACTj9cyjezTSYJYfMfg3p5fAACWjeF5\"",
"receivedDateTime": "2018-01-29T11:32:40Z",
"sentDateTime": "2018-01-29T11:32:37Z",
"subject": "New Mail",
"bodyPreview": "New email body for email preview",
"isRead": false,
"isDraft": false,
-- More properties are returned. Shortened response for brevity --
`
Email content data are acceessed via value.
Count of unread emails in Inbox folder is accessed via odata.count.
See Microsof Graph - List messages in a specified folder in the mailbox
Since JIRA API only allows to make a search request with a max result of 1000 issues, I need to know if there is a way to get the total number of issues a project so I can iterate through all thousands of issues.
IRestResponse responseIssues = client.Execute(new RestRequest("search?jql=project=" + "\"DATPROJECT\"" + "&maxResults=5000&fields=assignee,summary,timetracking,resolutiondate,resolution,worklog", Method.GET));
I am currently doing like the code above but I only get 1000 results and not 5000 that I need. I know that I can use the filter "startAt" to iterate over all results but I don't know how many issues exist.
Any ideas?
The search rest point returns total number of issues for a given JQL search. Example result from documentation
{
"expand": "names,schema",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": [
{
"expand": "",
"id": "10001",
"self": "http://www.example.com/jira/rest/api/2/issue/10001",
"key": "HSP-1"
}
]
}
This "total":1 value is the one you're looking for.
Hey from rest Api I don't find any rest where you can get all issue.but if you want all issue you can get it from java side. if you need total number of issues use
long getIssueCountForProject (Long projectId)
and if you want all issues and want to iterate it use
Collection<Long> getIssueIdsForProject (Long projectId)
please refer atlassian documentation for all this method.
Thank you.
You can use maxResults=0 to get only descriptive data omitting the actual results.
For example, if we want to know the amount of open issues for the currently logged in user:
rest/api/2/search?jql=project=SP+AND+statusCategory!=3+AND+assignee+in+(currentUser())&maxResults=0
The result:
{
"startAt": "0",
"maxResults": "0",
"total": "68",
"issues": [
]
}
The "total" field here is just what we need.
I have been able to retrieve event details using
#graph = Koala::Facebook::API.new(access_token)
#eventSummary = #graph.get_object(eventId)
and getting users list invited using
#eventSummary = #graph.get_connections(eventId, "invited")
I want to get count for all user invited, maybe, Declined and accepted for the event. for which i'm using
#eventSummary = #graph.get_connections(eventId, "invited?summary=1")
which again giving me the list of users only. when used graph.facebook like
https://graph.facebook.com/***eventId***/invited?access_token=*****access_token****&summary=1
i'm getting the count in result.
{
"data": [
{
"name": "xyz",
"rsvp_status": "attending",
"id": "10000000123"
}
],
"paging": {
"next": "https://graph.facebook.com/***eventId***/invited?summary=1&access_token=***accesstoken***&limit=5000&offset=5000&__after_id=100004389574321"
},
"summary": {
"noreply_count": 0,
"maybe_count": 0,
"declined_count": 0,
"attending_count": 1,
"count": 1
}
}
for just solving purpose i'm getting result using fql, as:
#eventSummary = #graph.get_object("fql", :q => "SELECT all_members_count, attending_count, declined_count, not_replied_count, unsure_count FROM event WHERE eid = #{eventId}")
But this is not convenient to use.
Can anyone please help, what am i doing wrong ? To get Event RSVP counts.
I'm using rails v.3.2, for facebook using Koala gem.
Thanks in advance.
I've seen it too, that when you request the event itself, those attendee count fields aren't included. You can use the second parameter to specifically ask for them though:
#eventSummary = #graph.get_object(eventId)
#eventSummary.merge(#graph.get_object(eventId, fields: "attending_count,declined_count,interested_count"))
The first call gets your "standard" event details, something like this:
{"description"=>"Blah blah blah",
"name"=>"My Event Will Rock",
"place"=>{"name"=>"Venue Bar",
"location"=>{"city"=>"Citytown",
"country"=>"United States",
"latitude"=>43.05308,
"longitude"=>-87.89614,
"state"=>"WI",
"street"=>"1216 E Brady St",
"zip"=>"53202"},
"id"=>"260257960731155"},
"start_time"=>"2016-04-22T21:00:00-0500",
"id"=>"1018506428220311"}
The second call gets just those "additional" requested fields:
{"attending_count"=>3,
"declined_count"=>0,
"interested_count"=>12,
"id"=>"1018506428220311"}
You can store them in separate variables, or as I'm suggesting above, use the hash#merge method. (There shouldn't be any problematic overlap between the keys of these two hashes.)
Alternatively, you can get all these details in one request by explicitly requesting everything you want.