Question

When the Zendesk server is down, our website - where we show some Forum content using Zendesk API - is down as well. We are currently using C# API like below:

ZendeskApi api = new ZendeskApi("https://companyname.zendesk.com/api/v2", "user", "pass");

GroupTopicResponse gtr = api.Topics.GetTopicsByForum(321321);

How can we set a timeout or skip this when the server is not available? We are using ASP.NET MVC 3.

Thanks.

Was it helpful?

Solution 2

We have solved with ASP.NET MVC caching, as explained in this post: https://stackoverflow.com/a/349111/261010

OTHER TIPS

In general, you want to make third-party API calls asynchronously.

  • I recommend you break out the Zendesk code into another controller and use an AJAX call to populate the forum data after the page loads. Then on a timeout, you can display an error message.
  • If you want to keep it server-side, you can wrap it in a method that starts a new thread and uses Thread.Join(TimeSpan) like in this answer: https://stackoverflow.com/a/1370891/1090474.

And if you want to get fancy, you can cache the results from Zendesk and in the case of a timeout, display the cached data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top