Skip to content

Commit

Permalink
Merge pull request #323 from zendesk/fvilela/add_user_agent
Browse files Browse the repository at this point in the history
[RED-2026] Set a default user agent so Zendesk can identify the requests
  • Loading branch information
mikerogers123 authored Nov 16, 2023
2 parents 26d60bc + f4dae7a commit c8b786d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ZendeskApi.Build/ZendeskApi.Commons.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PropertyGroup>
<Major>7</Major>
<Minor>0</Minor>
<Revision>5</Revision>
<Revision>6</Revision>
<PackageVersion>$(Major).$(Minor).$(Revision)</PackageVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/ZendeskApi.Client/ZendeskApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public HttpClient CreateClient(string resource = null)
var authorizationHeader = _options.GetAuthorizationHeader();

client.DefaultRequestHeaders.Add("Authorization", authorizationHeader);
client.DefaultRequestHeaders.UserAgent.ParseAdd("justeat.zendesk-api-client-csharp");

client.DefaultRequestHeaders
.Accept
Expand All @@ -73,7 +74,7 @@ public HttpClient CreateServiceStatusClient()
{
BaseAddress = new Uri("https://status.zendesk.com")
};

client.DefaultRequestHeaders.UserAgent.ParseAdd("justeat.zendesk-api-client-csharp");
client.DefaultRequestHeaders
.Accept
.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Expand Down
7 changes: 4 additions & 3 deletions src/ZendeskApi.Client/ZendeskApiClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public HttpClient CreateClient(string resource = null)

client.DefaultRequestHeaders
.Add(
"Authorization",
"Authorization",
authorizationHeader);
client.DefaultRequestHeaders.UserAgent.ParseAdd("justeat.zendesk-api-client-csharp");

client.DefaultRequestHeaders
.Accept
Expand All @@ -57,7 +58,7 @@ public HttpClient CreateServiceStatusClient()
.CreateClient();

client.BaseAddress = new Uri("https://status.zendesk.com");

client.DefaultRequestHeaders.UserAgent.ParseAdd("justeat.zendesk-api-client-csharp");
client.DefaultRequestHeaders
.Accept
.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Expand All @@ -68,4 +69,4 @@ public HttpClient CreateServiceStatusClient()
return client;
}
}
}
}

0 comments on commit c8b786d

Please sign in to comment.