diff --git a/includes/html/api_functions.inc.php b/includes/html/api_functions.inc.php
index 4177b4dcb5..f7a2b3d543 100644
--- a/includes/html/api_functions.inc.php
+++ b/includes/html/api_functions.inc.php
@@ -2914,7 +2914,7 @@ function get_location(Illuminate\Http\Request $request)
if (empty($location)) {
return api_error(400, 'No location has been provided to get');
}
- $data = ctype_digit($location) ? Location::find($location_id) : Location::where('location', $location)->first();
+ $data = ctype_digit($location) ? Location::find($location) : Location::where('location', $location)->first();
if (empty($data)) {
return api_error(404, 'Location does not exist');
}