Adding a try-catch around the rest call