php - View path return error 401 Bad credentials -


i building web api , stuck following issue. when call following path : localhost:8000/add browser returns

code":401,"message":"bad credentials 

here code: defaultcontroller.php (src/appbundle/controller/defaultcontroller.php)

    class defaultcontroller extends controller {     /*       * @route("/add", name="add_user")      */      public function addaction()     {     $number = mt_rand(0, 100);          return new response('lucky number: '.$number.' '         );     }  } 

routing.yml (app/config/routing.yml)

add_user: path:     /add defaults: { _controller: appbundle:default:add } 

any appreciated.

the bad credentials message tells security behind api , should use credentials access api.

and in opinion should return jsonresponse instead of response


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -