A .netstandard NuGet package for use with the Zendesk v2 API.
More detailed information on the exact changes and motivation can be found here.
For the sake of this library, it means the following methods have been removed:
IZendeskClient.ServiceStatus.ListComponents(...)
IZendeskClient.ServiceStatus.ListSubComponents(...)
IZendeskClient.ServiceStatus.GetComponentStatus(...)
IZendeskClient.ServiceStatus.GetSubComponentStatus(...)
In favour of the following:
IZendeskClient.ServiceStatus.ListActiveIncidents(...)
IZendeskClient.ServiceStatus.GetActiveIncident(...)
IZendeskClient.ServiceStatus.ListMaintenanceIncidents(...)
ZendeskApiClient now targets both .NET Standard 2.0 and .NET 6, enabling users to leverage the latest runtime features and performance optimizations for their projects. Please note that with this update, support for .NET Core 3.1 is no longer targeted.
This will allow for cursor pagination on some endpoints. We have kept the original offset pagination available so that this release is backward compatible, however due to Zendesk adding a variation of cursor pagination to this single endpoint, we have modified the original cursorPager
class to now be cursorPagerVariant
. If you use the TicketAudits endpoint please update your code.
Unfortunately Zendesk has not adopted cursor pagination on all endpoints. A list of compatible endpoints used in this API are as follows:
Users:
- GET /api/v2/deleted_users
- GET /api/v2/users
- GET /api/v2/users/{user_id}/identities
- GET /api/v2/user_fields
- GET /api/v2/users/{user_id}/groups
Groups:
- GET /api/v2/groups
- GET /api/v2/groups/{group_id}/users
Help Center:
- GET api/v2/help_center/articles
- GET api/v2/help_center/categories
Organization:
- GET /api/v2/organization_fields
- GET /api/v2/organization_memberships
- GET /api/v2/organizations
- GET /api/v2/organizations/{organization_id}/users
- GET /api/v2/organizations/{organization_id}/tickets
Tickets:
- GET /api/v2/deleted_tickets
- GET /api/v2/tickets
- GET /api/v2/tickets/{ticketId}/comments
- GET /api/v2/ticket_fields
- GET /api/v2/ticket_audits - Cursor Variant
Satisfaction ratings:
- GET /api/v2/satisfaction_ratings
Further reading on Zendesk Pagination changes
This is a complete rewrite so expect breaking changes.
Some noteworthy changes include:
PostAsync
replaced withCreateAsync
PutAsync
replaced withUpdateAsync
Search
resource now usesSearchAsync
instead ofFind
, and introduces a new fluent api to replace the oldZendeskQuery<T>
class.
To register this in your DI, you just need to call...
services.AddZendeskClient("https://[your_url].zendesk.com", "username", "token");
then you can inject in IZendeskClient anywhere you want to use it. Here you can access all the resources available.
If however you want to use the client in a DI less environment you can do this
var zendeskOptions = new ZendeskOptions
{
EndpointUri = "https://[your_url].zendesk.com",
Username = "username"
Token = "token"
};
var loggerFactory = new LoggerFactory();
var zendeskOptionsWrapper = new OptionsWrapper<ZendeskOptions>(zendeskOptions);
var client = new ZendeskClient(new ZendeskApiClient(zendeskOptionsWrapper), loggerFactory.CreateLogger<ZendeskClient>());
var ticket = await client.Tickets.GetAsync(1234L); // Get ticket by Id
var tickets = await client.Tickets.GetAllAsync(new [] { 1234L, 4321L }); //
var ticket = await client.Tickets.UpdateAsync(ticket);
var ticket = await client.Tickets.CreateAsync(ticket);
await client.Tickets.DeleteAsync(1234L);
await client.Search.SearchAsync<User>(q =>
q.WithFilter("email", "[email protected]")
);
await client.Search.SearchAsync<Organization>(q =>
q.WithFilter("name", "Cupcake Cafe")
);
// All non closed tickets
await client.Search.SearchAsync<Ticket>(q =>
q.WithFilter("status", "closed", FilterOperator.LessThan)
);
The zendesk api documentation is available at http://developer.zendesk.com/documentation/rest_api/introduction.html Querying and searching is limited by the searchable fields on the zendesk api
Please note that starting from August 15, 2023, if you make offset-based pagination (OBP) requests beyond the first 100 pages (10,000 records), you will receive an error message: "400 Bad Request." To retrieve data sets larger than 10,000 records, customers must transition to cursor-based pagination (CBP). You can find more information on the transition here. This library designates the OBP endpoints as
Obsolete
and introduces the new CBP endpoints in version 4.x.x. Therefore, users who wish to make the transition will need to upgrade.
In order to run integration tests against your own zendesk instance use the Cake script provided by:
.\build.ps1 --target=Run-Integration-Tests --zendeskUrl="<your zendesk url>" --zendeskUsername="<your zendesk username>" --zendeskToken="<your zendesk token>"
In Visual Studio, open the root folder of this project and open the test
view (has a little lightening bolt icon).
You should see a structure that looks like:
* ZendeskApiClient
* test
* ZendeskApi.Client.IntegrationTests
* ZendeskApi.Client.Tests
To run the integration tests, right click on it and select Run Test With
==> Custom Parameters
- make sure you add the following variables: ZendeskApi_Credentials_Url, ZendeskApi_Credentials_Username, ZendeskApi_Credentials_Token
You can save this configuration and give it a name, in order to run it multiple times.
We aim to follow Semantic Versioning guidelines within this library. When increasing the version please increment ZendeskApi.Commons.props.