Fresh Service is a cloud-based system that streamlines IT operations through its ticket management system, self-service portal, and a knowledge-based system. Let’s discuss how to integrate fresh service REST API inside the .NET application.
You have plenty of services here, let’s have the example of ticket integration in the .Net application. Before calling fresh service rest API, get the API key from the portal. You can find it in the settings section. Pass the API key in Authorization, select type as basic auth, and insert API key value in username parameter.
API Integration
First, refer to the Fresh Service documentation to get the URL and replace your domain name with the provided URL.
[HttpGet]
[Route("GetTickts")]
public TicketsListResponse GetTickts()
{
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization=new AuthenticationHeaderValue("Basic", GetAuthToken());
var response= httpClient.GetAsync("https://athentech.freshservice.com/api/v2/tickets").Result;
var content = response.Content.ReadAsStringAsync().Result;
TicketsListResponse ticketsListResponse= JsonConvert.DeserializeObject<TicketsListResponse>(content);
return ticketsListResponse;
}
Create GetTickets
method to get all the ticket information against the user. and also implement the GetTicketsById
method to retrieve the single information from the list of tickets against the user. You can also apply filters to customize the responses.
[HttpGet]
[Route("GetTicktsById/{id}")]
public TicketResponse GetTicktsById(int id)
{
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization=new AuthenticationHeaderValue("Basic", GetAuthToken());
var response = httpClient.GetAsync("https://athentech.freshservice.com/api/v2/tickets/"+id).Result;
var content = response.Content.ReadAsStringAsync().Result;
TicketResponse ticketsListResponse = JsonConvert.DeserializeObject<TicketResponse>(content);
return ticketsListResponse;
}
Fresh Service version 2 introduces new features, such as rate limits, improved error handling, support for JSON, pagination sizes of up to 100, and Cross-Origin Resource Sharing (CORS) support.
This integration allows you to seamlessly incorporate Fresh Service’s functionality into your .NET application for efficient IT operations and ticket management.
No Comment! Be the first one.