Guard against undefined 'body' in apiRequest
Handle case of error in header with empty body