Fix query hack.
Throw more debugging info when an api call fails.