How do I return all the metadata from the Mail REST API that is part of Office 365 APIs Preview?
The msdn docs seem to be indicating that you send an Accept header with the value of "application/json;odata.metadata=full", but that results in the limited number of properties being returned and doesn't include the body of the email.
http://msdn.microsoft.com/en-us/library/office/dn605901(v=office.15).aspx
I have also tried "odata=verbose" with the same result. Here is the json that gets returned in either case:
{
"@odata.context":"",
"@odata.id":"",
"@odata.editLink":"",
"Id":"",
"Subject":"",
"DateTimeReceived":"",
"From":{},
"Attachments@odata.navigationLink":""
}
UPDATE:
REST endpoint:
https://outlook.office365.com/ews/odata/Me/Inbox/Messages
Rohit Nagarmal's answer pointed me in the right direction. I had a list of fields specified in the $select query parameter, which was overriding the Accept header's full metadata setting. Once I removed the $select query, full metadata was returned.
Can you share the url you are using to access the Messages?
If you are using something like:
https://outlook.office365.com/ews/odata/Me/Inbox/Messages
you should be seeing the Body property in the response.
You can also specifically request selective properties using $select. For example:
https://outlook.office365.com/ews/odata/Me/Inbox/Messages?$select=Subject,Body&$top=1
$top can be used to restrict the number of items returned.
If $select is specified, it will override the Accept="odata.metadata=full" setting and will return just the fields specified in the $select query.
Most likely this is not even on your radar anymore.. but this worked for me.
public async void GetFolderMessagesList(string parentFolderId, OnFeedBackMessage onFeedBackMessage, OnErrorMessage onErrorMessage)
{
try
{
jsonLastRun = "";
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get,
new Uri(("https://outlook.office365.com/api/v1.0/me/folders/{ChangeThisToFolder_id}/messages")));
// Add the Authorization header with the basic login credentials.
var auth = "Basic " +
Convert.ToBase64String(
Encoding.UTF8.GetBytes(UserAccount + ":" + PassWord));
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", auth);
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
jsonLastRun = await response.Content.ReadAsStringAsync();
}
catch (Exception exception)
{
onErrorMessage?.Invoke("GetFolderList -> " + exception.Message);
}
}