diff --git a/lib/private/api.php b/lib/private/api.php
index 748876909520285c35e8f82443c2ff4dd6374c88..e9c144564f0a684e5efa0bfb3f06e022a2515f4c 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -301,7 +301,7 @@ class OC_API {
 	 * @param OC_OCS_Result $result
 	 * @param string $format the format xml|json
 	 */
-	private static function respond($result, $format='xml') {
+	public static function respond($result, $format='xml') {
 		// Send 401 headers if unauthorised
 		if($result->getStatusCode() === self::RESPOND_UNAUTHORISED) {
 			header('WWW-Authenticate: Basic realm="Authorisation Required"');
diff --git a/ocs/v1.php b/ocs/v1.php
index 624355a850122fc3fb684b6588748313861da17b..0a86fb064117c2d45fe6c492714c3dd27d1ae46f 100644
--- a/ocs/v1.php
+++ b/ocs/v1.php
@@ -27,7 +27,8 @@ if (\OCP\Util::needUpgrade()) {
 	// since the behavior of apps or remotes are unpredictable during
 	// an upgrade, return a 503 directly
 	OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
-	OC_Template::printErrorPage('Service unavailable');
+	$response = new OC_OCS_Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
+	OC_API::respond($response, OC_API::requestedFormat());
 	exit;
 }