Added error handling to catch API not set.