I am trying to get the metadata from Office 365 Management APIs. When I a make a call to the following Url
resource = "https://manage.office.com/api/v1.0/tenant-id/ServiceComms/Messages"
I get the response and in the content, I have the following information (I have replaced the tenant GUID with name):
{
"@odata.context": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/$metadata#Messages",
"value": [
{
"@odata.type": "#Microsoft.Office365ServiceComms.ExposedContracts.Message",
"@odata.id": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/Messages('LY177449')",
"@odata.editLink": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/Messages('LY177449')",
"[email protected]": "#Collection(String)",
"AffectedWorkloadDisplayNames": [],
"[email protected]": "#Collection(String)",
"AffectedWorkloadNames": [
From the response I assumed that I can retrieve metadata from https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/$metadata
But when I make an auth call to that Url I just get an Internal server error msg
string resource =
"https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/$metadata";
using(HttpClient httpClient = new HttpClient())
{
httpClient.Timeout = new TimeSpan(0, 2, 0);
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", _authResult.AccessToken);
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
HttpResponseMessage response = await httpClient.GetAsync(resource);
}
In httpClient
, I have 2 headers, the Authorization: bearer token
(which works fine) and Accept: application/json
In HttpResponseMessage response
, I get a 500 Internal Server Error
. There is no other information.
I don't understand what I am doing wrong here. Does anyone know how to get the metadata from Office 365 Service Communications API?