.NET Client for Wrike API. Feel free to show your ❤️ by giving a ⭐ and / or my coffe expenses
Create your Wrike Client and just call the function you need.
var client = new WrikeClient("permanent_token");
//create the authorization url
var authorizationUrl = WrikeClient.GetAuthorizationUrl(
ClientId,
redirectUri: "http://localhost",
state: "myTestState",
scope: new List<string> { WrikeScopes.Default, WrikeScopes.wsReadWrite });
//After the user authorizes your client using the authroization url,
//wrike will redirect user to the provided redirect_uri with the authorization code
//See https://developers.wrike.com/documentation/oauth2 for more details
//create client
var client = new WrikeClient(new WrikeAccessTokenRequest(
ClientId,
ClientSecret,
AuthorizationCode), "redirect_uri");
//refresh token if needed
client.RefreshToken();
var accesTokenResponse = WrikeClient.GetAccesToken(new WrikeAccessTokenRequest(
ClientId,
ClientSecret,
AuthorizationCode), "http://localhost");
var client = new WrikeClient(accesTokenResponse.AccessToken, accesTokenResponse.Host);
//you need new client when you need to refresh token
var refreshTokenResponse = WrikeClient.RefreshToken(ClientId, ClientSecret,
accesTokenResponse.RefreshToken, accesTokenResponse.Host);
client = new WrikeClient(refreshTokenResponse.AccessToken, accesTokenResponse.Host);
//create client
var client = new WrikeClient("permanent_token");
//get the list of custom fields
//https://developers.wrike.com/documentation/api/methods/query-custom-fields
var customFields = await client.CustomFields.GetAsync();
//create new custom field
//https://developers.wrike.com/documentation/api/methods/create-custom-field
var newCustomField = new WrikeCustomField("Title", WrikeCustomFieldType.Text);
newCustomField = await client.CustomFields.CreateAsync(newCustomField);
//delete a task
await client.Tasks.DeleteAsync("taskId");
By default, we use the classic new HttpClient()
way of instantiating our own instance of HttpClient
. We do, however, provide a way for you to pass in your own customized implementation of it so that you can use whatever custom Policies, Throttling, etc. that you require.
The recommended way of creating HttpClients
is using IHttpClientFactory
as specified by the official Microsoft docs here
In order to provide your own instance of HttpClient for this library to use, you simply need to provide it in the constructor for WrikeHttpClient
:
var client = new WrikeClient("permanent_token", customHttpClient: customHttpClientImplementation);
For more details on usage checkout the Taviloglu.Wrike.ApiClient.Samples project
Create your WrikeWebHookController by subclassing and implementing WrikeWebHookControllerBase abstract class provided in Taviloglu.Wrike.WebHook library. Don't forget to set a route to your new controller.
[Route("api/[controller]")]
public class WrikeWebHookController : WrikeWebHookControllerBase
{
protected override void OnAttachmentAdded(WrikeWebHookEvent wrikeWebHookEvent)
{
throw new NotImplementedException();
}
/*
implement other events...
*/
}
When your WrikeWebHookController is ready for responding to post requests, create a webhook using the Wrike Client
//create client
var client = new WrikeClient("permanent_token");
//create new webhook
//https://developers.wrike.com/documentation/webhooks
var newWebHook = new WrikeWebHook("https://<your-host>/api/wrikewebhook");
newWebHook = await client.WebHooks.CreateAsync(newWebHook);
Then Wrike will send post requests to the url you provided. For more details check out wrike's documentation
Note: WrikeWebHook library uses Newtonsoft.json serializer, which is not default serializer on ASP.NET Core 3.0+ or Framework 5.0+ versions. On recent ASP.NET projects you may need to install Microsoft.AspNetCore.Mvc.NewtonsoftJson package and activate it as follows;
services.AddControllers().AddNewtonsoftJson();
See Issue#33
Endpoint | IsImplemented | Group |
---|---|---|
[GET] /contacts | 1 | Contacts |
[GET] /contacts/{contactId},{contactId},... - up to 100 IDs | 1 | |
[PUT] /contacts/{contactId} | 1 | |
[GET] /users/{userId} | 1 | Users |
[PUT] /users/{userId} | 1 | |
[GET] /groups/{groupId} | 1 | Groups |
[GET] /groups | 1 | |
[POST] /groups | 1 | |
[PUT] /groups/{groupId} | 1 | |
[DELETE] /groups/{groupId} | 1 | |
[GET] /invitations | 1 | Invitations |
[POST] /invitations | 1 | |
[PUT] /invitations/{invitationId} | 1 | |
[DELETE] /invitations/{invitationId} | 1 | |
[GET] /account | 1 | Accounts |
[PUT] /account | 1 | |
[GET] /workflows | 1 | Workflows |
[POST] /workflows | 1 | |
[PUT] /workflows/{workflowId} | 1 | |
[GET] /customfields | 1 | Custom Fields |
[GET] /customfields/{customfieldId},{customfieldId},... - up to 100 Ids | 1 | |
[POST] /customfields | 1 | |
[PUT] /customfields/{customfieldId} | 1 | |
[GET] /folders | 1 | Folders & Projects |
[GET] /folders/{folderId}/folders | 1 | |
[GET] /folders/{folderId},{folderId},... - up to 100 IDs | 1 | |
[POST] /folders/{folderId}/folders | 1 | |
[POST] /copy_folder/{folderId} | 1 | |
[PUT] /folders/{folderId} | 1 | |
[DELETE] /folders/{folderId} | 1 | |
[GET] /tasks | 1 | Tasks |
[GET] /folders/{folderId}/tasks | 1 | |
[GET] /tasks/{taskId},{taskId},... - up to 100 IDs | 1 | |
[POST] /folders/{folderId}/tasks | 1 | |
[PUT] /tasks/{taskId} | 1 | |
[DELETE] /tasks/{taskId} | 1 | |
[GET] /comments | 1 | Comments |
[GET] /folders/{folderId}/comments | 1 | |
[GET] /tasks/{taskId}/comments | 1 | |
[GET] /comments/{commentId},{commentId},... - up to 100 Ids | 1 | |
[POST] /folders/{folderId}/comments | 1 | |
[POST] /tasks/{taskId}/comments | 1 | |
[PUT] /comments/{commentId} | 1 | |
[DELETE] /comments/{commentId} | 1 | |
[GET] /tasks/{taskId}/dependencies | 1 | Dependencies |
[GET] /dependencies/{dependencyId},{dependencyId},... - up to 100 IDs | 1 | |
[POST] /tasks/{taskId}/dependencies | 1 | |
[PUT] /dependencies/{dependencyId} | 1 | |
[DELETE] /dependencies/{dependencyId} | 1 | |
[GET] /timelogs | 1 | Timelogs |
[GET] /contacts/{contactId}/timelogs | 1 | |
[GET] /folders/{folderId}/timelogs | 1 | |
[GET] /tasks/{taskId}/timelogs | 1 | |
[GET] /timelog_categories/{timelog_categoryId}/timelogs | 1 | |
[GET] /timelogs/{timelogId} | 1 | |
[POST] /tasks/{taskId}/timelogs | 1 | |
[PUT] /timelogs/{timelogId} | 1 | |
[DELETE] /timelogs/{timelogId} | 1 | |
[GET] /timelog_categories | 1 | Timelog Categories |
[GET] /attachments | 1 | Attachments |
[GET] /folders/{folderId}/attachments | 1 | |
[GET] /tasks/{taskId}/attachments | 1 | |
[GET] /attachments/{attachmentId},{attachmentId},... - up to 100 Ids | 1 | |
[GET] /attachments/{attachmentId}/download | 1 | |
[GET] /attachments/{attachmentId}/preview | 1 | |
[GET] /attachments/{attachmentId}/url | 1 | |
[POST] /folders/{folderId}/attachments | 1 | |
[POST] /tasks/{taskId}/attachments | 1 | |
[PUT] /attachments/{attachmentId} | 1 | |
[DELETE] /attachments/{attachmentId} | 1 | |
[GET] /version | 1 | Version |
[GET] /ids | 1 | Ids |
[GET] /colors | 1 | Colors |
[POST] /folders/{folderId}/webhooks | 1 | Webhooks |
[GET] /webhooks | 1 | |
[GET] /webhooks/{webhookId},{webhookId} | 1 | |
[PUT] /webhooks/{webhookId} | 1 | |
[DELETE] /webhooks/{webhookId} | 1 | |
[POST] https://www.wrike.com/oauth2/token (getToken) | 1 | oAuth2.0 |
[POST] https://www.wrike.com/oauth2/token (refreshToken) | 1 |