Switch API repository to use nested exception

We can switch this to use exception causes once we can upgrade
to Ruby 2.1.

See http://devblog.avdi.org/2013/12/25/exception-causes-in-ruby-2-1/