Skip to content

Commit

Permalink
changed requet to request in defaultRequetHeaders (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
coxantohi authored Jun 14, 2020
1 parent c47356c commit 6d407de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions 1-Call-MSGraph/daemon-console/ProtectedApiCallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ public async Task CallWebApiAndProcessResultASync(string webApiUrl, string acces
{
if (!string.IsNullOrEmpty(accessToken))
{
var defaultRequetHeaders = HttpClient.DefaultRequestHeaders;
if (defaultRequetHeaders.Accept == null || !defaultRequetHeaders.Accept.Any(m => m.MediaType == "application/json"))
var defaultRequestHeaders = HttpClient.DefaultRequestHeaders;
if (defaultRequestHeaders.Accept == null || !defaultRequestHeaders.Accept.Any(m => m.MediaType == "application/json"))
{
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
defaultRequetHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
defaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken);

HttpResponseMessage response = await HttpClient.GetAsync(webApiUrl);
if (response.IsSuccessStatusCode)
Expand Down
6 changes: 3 additions & 3 deletions 2-Call-OwnApi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ The relevant code for this sample is in the `Program.cs` file, in the `RunAsync(
In this sample, we are calling "https://localhost:44372/api/todolist" with the access token as a bearer token.

```CSharp
var defaultRequetHeaders = HttpClient.DefaultRequestHeaders;
var defaultRequestHeaders = HttpClient.DefaultRequestHeaders;

if (defaultRequetHeaders.Accept == null || !defaultRequetHeaders.Accept.Any(m => m.MediaType == "application/json"))
if (defaultRequestHeaders.Accept == null || !defaultRequestHeaders.Accept.Any(m => m.MediaType == "application/json"))
{
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}

defaultRequetHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
defaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
```

### TodoList Web API Code
Expand Down
6 changes: 3 additions & 3 deletions 2-Call-OwnApi/daemon-console/ProtectedApiCallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public async Task CallWebApiAndProcessResultASync(string webApiUrl, string acces
{
if (!string.IsNullOrEmpty(accessToken))
{
var defaultRequetHeaders = HttpClient.DefaultRequestHeaders;
if (defaultRequetHeaders.Accept == null || !defaultRequetHeaders.Accept.Any(m => m.MediaType == "application/json"))
var defaultRequestHeaders = HttpClient.DefaultRequestHeaders;
if (defaultRequestHeaders.Accept == null || !defaultRequestHeaders.Accept.Any(m => m.MediaType == "application/json"))
{
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
defaultRequetHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
defaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken);

HttpResponseMessage response = await HttpClient.GetAsync(webApiUrl);
if (response.IsSuccessStatusCode)
Expand Down

0 comments on commit 6d407de

Please sign in to comment.