Fetch messages filtered by conversationId via Office365 API - outlook

I'm having some trouble figuring out how to use the office365 api to fetch messages given a conversationId.
Let's say my conversationId is AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow=
I'll make a request like
https://outlook.office.com/api/v1.0/me/Messages?$filter=ConversationId%20eq%20AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow=
This results in a 400 response like this:
{
"error": {
"code": "RequestBroker-ParseUri",
"message": "Syntax error at position 98 in 'ConversationId eq AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow='."
}
}
I tried other things, such as url encoding the conversationId to AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow%3D which results in the same error.
I also tried simply removing the = which seems to be the character that is freaking it out
https://outlook.office.com/api/v1.0/me/Messages?$filter=ConversationId%20eq%20AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow
but that results in the following error
{
"error": {
"code": "RequestBroker-ParseUri",
"message": "Could not find a property named 'AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow' on type 'Microsoft.OutlookServices.Message'."
}
}
I've also tried messing with the url capitalization and using + signs instead of %20 for the filter string, but I consistently get 400 errors back.
I am able to filter by other fields though. For example
https://outlook.office.com/api/v1.0/me/Messages?$filter=IsRead%20eq%20true
returns messages filtered as I would expect.
Any idea what could be going on with the ConversationId filter?

You need to wrap the ConversationId with single quotes.
This is how I forge my request in C#
string finalUrl = "https://outlook.office.com/api/beta/me/Messages?$filter=" + HttpUtility.UrlEncode(string.Format("ConversationId eq '{0}'", conversationId));

Related

mediaItems missing from Media.ListCustomerMediaItems

When sending the GET request to the following URI
https://mybusiness.googleapis.com/v4/accounts/XXXX/locations/YYYY/media/customers
i get a response that consists of 'nextPageToken' with token for next page, and 'totalMediaItemCount' which says '30' because that's the number of customer media items in the account i use.
According to the docs here:
https://developers.google.com/my-business/reference/rest/v4/accounts.locations.media.customers/list
i am supposed to get this response:
{
"mediaItems": [
{
object (MediaItem)
}
],
"totalMediaItemCount": integer,
"nextPageToken": string
}
but even though it says that i have 30 customer media items, the 'mediaItems' is missing from the response.
is there a problem with the API or am i doing something wrong?

How to get details of high importance mails via Graph API

I am trying to get list of mails that are with high importance via Graph API.
For that, I am using below query:
https://graph.microsoft.com/v1.0/me/messages?$select=importance,subject
But that's not working out as it is giving all :(
I found that I have to add filter in the query and tried like below:
https://graph.microsoft.com/v1.0/me/messages?$select=importance,subject &
$filter=importance eq high
But I'm getting error like below:
{
"error": {
"code": "RequestBroker--ParseUri",
"message": "Could not find a property named 'high' on type 'Microsoft.OutlookServices.Message'.",
"innerError": {
"date": "2022-06-10T04:29:52",
"request-id": "",
"client-request-id": ""
}
}
}
I think I'm using query in a wrong way. Can anyone suggest me what's wrong?
Use single quotation mark '' for the specific name of the importance
https://graph.microsoft.com/v1.0/me/messages?$select=importance,subject&$filter=importance eq 'high'

Fetch Exchange online message details using InternetMessageId

When I get an event of SendAs (from other MS audit source) it contains very little info of the message itself, but has an InternetMessageId identifier.
I'm trying to fetch additional info using it but get only errors.
Firstly w/ the MessageTraceDetail report, I tried to fetch by either using the InternetMessageId as MessageId and as MessageTraceId, both return w/ same error:
GET https://reports.office365.com/ecp/reportingwebservice/reporting.svc/MessageTraceDetail
with query: "$filter" -> "MessageId eq guid'<AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE#mycorp.onmicrosoft.com>'"
{
"odata.error": {
"code": "",
"message": {
"lang": "en-US",
"value": "Unrecognized 'Edm.Guid' literal 'guid'<AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE#mycorp.onmicrosoft.com>'' at '13' in 'MessageId eq guid'<AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE#mycorp.onmicrosoft.com>''."
}
}
}
Secondly, w/ the Microsoft Graph API of get message
I created an AD App and granted it both Application and Delegated permissions of all "mail" related.
The request was w/ user principal name and the message id:
GET https://graph.microsoft.com/beta/users/myuser#mycorp.onmicrosoft.com/messages/%3AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE#mycorp.onmicrosoft.com%3E
which produces a generic 500 Internal Server Error.
What am I doing wrong?
Is there any other API to use that allow the get the message details using the InternetMessageId ?
GET https://reports.office365.com/ecp/reportingwebservice/reporting.svc/MessageTraceDetail
with query: "$filter" -> "MessageId eq guid''"
While the MessageId can contain a GUID it's not a Guid datatype so just query it as a String however you will need to escape the string to use it eg
System.Uri.EscapeDataString(("MessageId eq '" + InternetMessageId + "'")
https://graph.microsoft.com/beta/users/myuser#mycorp.onmicrosoft.com/messages/%3AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE#mycorp.onmicrosoft.com%3E
the id being referred to here is the Exchange Store identifier for the item which is different from the InternetMessageId you have to search for the Message using the InternetMessageId eg
https://graph.microsoft.com/v1.0/me/messages?$filter=internetMessageId eq '<AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE#mycorp.onmicrosoft.com>'
You could try to the following request of Graph API:
https://graph.microsoft.com/v1.0/me/messages?$filter=internetMessageId eq '<1430948481468.34600#THCIE7Dev2.onmicrosoft.com>'
For more, please see the link:
Microsoft Graph API - find message by internetmessageid

user.messages.get responding invalid ID

when attempting to test out the api explorer for user.messages: get I have been getting an invalid message ID response.
I am getting the message ID from a recent email in my inbox sent to me, and removed the <> from either ends.
response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid id value"
}
],
"code": 400,
"message": "Invalid id value"
}
}
I am a bit confused as I am using the powershell module gshell and noticed that the same messageID worked in my commands but returned invalid id value in the api explorer.
edit: if I do a inbox search for rfc822msgid:[messageID] it returns the correct message
First you have to call the users.messages.list api. It will give a list of messageids. Then we have to call users.message.get api with each messageid to fetch the mail content. You can query the mails with advanced search options provided by Gmail API.
You should not use the rfc822msgid, but the Gmail API message id. Try to list messages and use the id you get from that when getting the message.

Mailchimp API 2.0 lists/subscribe responding with error 250 List_MergeFieldRequired MMERGE4 is required

I'm attempting to use the lists/subscribe Mailchimp API 2.0 endpoint to subscribe an email to a list, but I keep getting a puzzling error. My request looks like:
{
"apikey":"myapikey-us5",
"id":"listid",
"email":{"email":"my#email.com"},
"double_optin":false,
"send_welcome":true
}
I'm sending this to https://us5.api.mailchimp.com/2.0/lists/subscribe.json and getting this response:
{
"status": "error",
"code": 250,
"name": "List_MergeFieldRequired",
"error": "MMERGE4 must be provided - Please enter a value"
}
And if I specify "merge_vars": {} I still get the same error. What am I missing here?
It means you need to provide a value for MMERGE4 merge field. How you do this depends on what type of merge field MMERGE4 is, but It would be like this:
{
"apikey":"myapikey-us5",
"id":"listid",
"email":{"email":"my#email.com"},
"double_optin":false,
"send_welcome":true,
"merge_vars": {
"MMERGE4": "something"
}
}
But you should look and see what type of data that is, otherwise you might cause issues for whomever set that up as a required field.

Resources