RestApi: Improved token authorization and handling of the 405 error