Thanks Kobaltz, i figured it out that i was using my application controller not the one which is present under api folder.
But there is a different problem now, i am trying to get information from students controller, and it doesn't work because of this line in the controller:
before_action :authenticate_user!
(P.S. I am using devise)
Do you suggest?