Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Web API App-Only with Graph API
[HttpGet]
public async Task<IActionResult> Get()
{
...
try
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var url = $"{this._graphUrl}/{this._version}/{Organisation}";
var resultAsString = await client.GetStringAsync(url);
var organisation = JObject.Parse(resultAsString);
var result = new JsonResult(organisation);
return result;
}
}
catch (Exception ex)
{
var result = new JsonResult(ex);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.