diff --git a/lib/private/api.php b/lib/private/api.php
index 75d87b333d5de6a9cb941acdc37da7b9eea4975a..f5576af2ad822d57c5a4e62c426be4caabccac39 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -65,6 +65,7 @@ class OC_API {
 		$name = strtolower($method).$url;
 		$name = str_replace(array('/', '{', '}'), '_', $name);
 		if(!isset(self::$actions[$name])) {
+			$oldCollection = OC::$server->getRouter()->getCurrentCollection();
 			OC::$server->getRouter()->useCollection('ocs');
 			OC::$server->getRouter()->create($name, $url)
 				->method($method)
@@ -72,7 +73,7 @@ class OC_API {
 				->requirements($requirements)
 				->action('OC_API', 'call');
 			self::$actions[$name] = array();
-			OC::$server->getRouter()->useCollection('root');
+			OC::$server->getRouter()->useCollection($oldCollection);
 		}
 		self::$actions[$name][] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel);
 	}
diff --git a/lib/private/route/router.php b/lib/private/route/router.php
index f3a4bc5f3e4a5819af63b87121bb2a8a88951698..9c973d7ac6ae6e10da285ca8ea8b1a6ebc917a40 100644
--- a/lib/private/route/router.php
+++ b/lib/private/route/router.php
@@ -25,6 +25,11 @@ class Router implements IRouter {
 	 */
 	protected $collection = null;
 
+	/**
+	 * @var string
+	 */
+	protected $collectionName = null;
+
 	/**
 	 * @var \Symfony\Component\Routing\RouteCollection
 	 */
@@ -160,8 +165,19 @@ class Router implements IRouter {
 	 */
 	public function useCollection($name) {
 		$this->collection = $this->getCollection($name);
+		$this->collectionName = $name;
+	}
+
+	/**
+	 * returns the current collection name in use for adding routes
+	 *
+	 * @return string the collection name
+	 */
+	public function getCurrentCollection() {
+		return $this->collectionName;
 	}
 
+
 	/**
 	 * Create a \OC\Route\Route.
 	 *
diff --git a/lib/public/route/irouter.php b/lib/public/route/irouter.php
index 1c003c7b4b91c2c7d5a6b126a3ec89309b469767..daa1632e0c87c66681e883210a8faa4b00778207 100644
--- a/lib/public/route/irouter.php
+++ b/lib/public/route/irouter.php
@@ -36,6 +36,13 @@ interface IRouter {
 	 */
 	public function useCollection($name);
 
+	/**
+	 * returns the current collection name in use for adding routes
+	 *
+	 * @return string the collection name
+	 */
+	public function getCurrentCollection();
+
 	/**
 	 * Create a \OCP\Route\IRoute.
 	 *