Pretty generate JSON as file. Catch API error