Updated the class casting so that it works for rest requests also