diff --git a/plugins/API/API.php b/plugins/API/API.php
index 7548cf312b37df4fb29e6edd04bae21f3beac1b7..b3d2fa49a808c2cf81f9501dd84f51db5b4431e4 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -276,7 +276,11 @@ class API extends \Piwik\Plugin\API
                                       $showSubtableReports = false, $idSite = false)
     {
         if (empty($idSite) && !empty($idSites)) {
-            $idSite = array_shift($idSites);
+            if (is_array($idSites)) {
+                $idSite = array_shift($idSites);
+            } else {
+                $idSite = $idSites;
+            }
         } elseif (empty($idSites)) {
             throw new \Exception('Calling API.getReportMetadata without any idSite is no longer supported since Piwik 3.0.0. Please specifiy at least one idSite via the "idSite" parameter.');
         }