In Microsoft Graph API, how do you retrieve a specific mail using the Id (Mail ID)?
This is what I tried :
$filter => "Id eq 'AQMkADYwZWEyZDQy...someRandomID'"
but the response I get is the property id does not support filtering
Yes. The property 'Id' does not support filtering for List messages.
You should retrieve a specific mail using the Id (Mail ID) through Get message.
GET https://graph.microsoft.com/v1.0/me/messages/{Mail ID}
Related
I'm developing an Outlook add-in, in which I grab the mailbox item id and send it to an API. The API uses the Microsoft Graph SDK to fetch the message item by the given id. This scenario worked fine so far, but now I'm struggling with a strange format mismatch between the id I get from Office.js and the id from Graph.
Office.context.mailbox.item.itemId returns ...MlPrBwD/Cohwu0F...
Graph returns ...MlPrBwD-Cohwu0F
So Office.js returns the id containing /C where Graph returns -C in it.
Any ideas?
I'm not sure but I think that the id returned by Office.context.mailbox.item.itemId is an EWS item id.
You can convert it to rest/graph item id by using Office.context.mailbox.convertToRestId.
Is there a way to get the email aliases address to which an email was originally sent from Microsoft Graph?
We have a single email account like main#company.com along with the multiple other associated email addresses (email aliases). Emails send to any of the aliases go to a to the same inbox as main#company.com.
If we send an email to alias#company.com and look at the message using https://graph.microsoft.com/v1.0/me/messages, it shows mail#company.com as the email address. We need to detect if it was sent to alias#company.com.
The information for the allies can be found in the email header and there is a potential workaround in the Outlook API:
https://outlook.office.com/api/v2.0/me/mailfolders/inbox/messages/{messageId}?$select=Subject,SingleValueExtendedProperties &$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String 0x7D')
This returns an unstructured result which needs to be parsed and it is not very convenient. We are looking if there is a more direct way to get this from Microsoft Graph.
You can use the same $filter with Microsoft Graph. You simply need to switch PropertyId to simply id:
?$select=subject&$expand=singleValueExtendedProperties($filter=id eq 'String 0x7D')
Also note that don't need to both select and expand the singleValueExtendedProperties collection. Expanding will ensure it gets included.
We have integrated outlook to our iOS application using Microsoft Graph API. We have a use case where we have to filter outlook messages by attachment name or by subject. We are using query parameters to hit graph API.
Link to microsoft documentation.
As per above documentation, $search parameter is used to filter outlook messages. When are hitting below API, we are getting wrong responses. It’s returning messages which have “Test Mail” in both subject and message body. But it should return only the messages whose subject line is “Test Mail”.
https://graph.microsoft.com/v1.0/me/messages?$search="subject:Test Mail”
The same problem we are facing when we filter messages by attachment name, by hitting below API. In fact we are getting a empty response in this case.
https://graph.microsoft.com/v1.0/me/messages?$search=“attachments:test.png”
Is the above URL formation is correct? Why we’re not getting desired response? Please help us out on this.
For searching Subject only, you can use:
/v1.0/me/messages?$search="subject:search term"
or a filter:
/v1.0/me/messages?$filter=contains(subject, 'my search term')
(in this method the search term must exactly match a portion of the subject string)
For searching attachments only, you must use the keyword 'attachment' instead of 'attachments' (exchange documentation):
/v1.0/me/messages?$search="attachment:search term"
From the documentation, I can't find any ways to get the siteId of the site where I put the webpart in.
For example,
My current site is: https://{hostname}/sites/main1 <-- NOT root site, but I want to get this siteId
and I test my webpart here: https://{hostname}/sites/main1/_layouts/15/workbench.aspx
How can I achieve this? From the documentation,
A site is addressed be a unique identifier which is a composite ID of the following values:
Site collection hostname (contoso.sharepoint.com)
Site collection unique ID (guid)
Site unique ID (guid)
I can get the hostname easily by using location.hostname (Yes, I am using JavaScript + React to build my webpart) but how to get the site-id easily with Graph API?
Try this: https://graph.microsoft.com/v1.0/sites/{hostname}:/sites/{path}?$select=id
For example:
https://graph.microsoft.com/v1.0/sites/cie493742.sharepoint.com:/sites/Contoso/Operations/Manufacturing?$select=id (this one you can try on the Graph Explorer.
What you get back in the id is in this format:
{hostname},{spsite.id},{spweb.id}
For more info here is the link to the docs: https://learn.microsoft.com/en-us/graph/api/resources/sharepoint?view=graph-rest-1.0
You don't need to do a Graph API call to get the siteId of the current site. It is available in the PageContext.
In the main class of your webpart you can find it at:
this.context.pageContext.site.id
On classic sites using spPageContextInfo:
(location.host + "," + _spPageContextInfo.siteId + "," + _spPageContextInfo.webId).replace(/[\{\}]/g, "")
Execute the below query in Graph explorer
https://graph.microsoft.com/v1.0/sites/{tenantname}.sharepoint.com:/sites/{sitename}
replace the tenantname and sitename placeholders.
The key 'Id' in the JSON response holds the site Id value
Another way you can get the Site-id by below Graph Http Get API.
https://graph.microsoft.com/v1.0/sites
I've to call this Twitter API's method
https://api.twitter.com/1.1/lists/statuses.json?list_id=12345
to retrieve the tweets by the user in the list.
But my customer provide me only the name of the list and I've no idea how to get the list id using the list name.
The list is this: https://twitter.com/DatasportNews/lists/i-campioni-di-brasile2014.
I've tried with this method
https://api.twitter.com/1.1/lists.json?screen_name=i-campioni-di-brasile2014
to get the id list but always return this message
{"errors":[{"message":"Your credentials do not allow access to this resource","code":220}]}.
I'm logged with api key and api secret and get the token well, but this method doesn't work.
Ideas ?
The list name in the URL is referred to as the slug. When you want to request statuses from a list using a slug, you simply also need to pass the owner_screen_name.
For example, in your case:
/1.1/lists/statuses.json?slug=i-campioni-di-brasile2014&owner_screen_name=DatasportNews
More details on this are on the endpoint's doc page at https://dev.twitter.com/docs/api/1.1/get/lists/statuses