Laravel restful api error 500(store and destroy) -


i new restful api,and met problem,problem :when request destroy delete method , store post method,both return 500 error.but use method request index , show,both ok.what problem? here codes , request:

delete http://***.com/restfulprac/public/customers/10000001

get http://***.com/restfulprac/public/customers/10000001

post http://***.com/restfulprac/public/customers


 class customerscontroller extends controller  {     public function index(){      $customersinfo = customers::all();     return $customersinfo;      }      public function show($cust_id){      $customer = customers::where('cust_id',$cust_id)->first();     return $customer;     }     public function store()     {      echo "store";     }     public function destroy()    {        return "success";    } } 

route::resource('customers','customerscontroller'); 

the apache access.log : "delete /restfulprac/public/customers/1000000001 http/1.0" 500 20246 "-" "mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/50.0.2661.102 safari/537.36"

the apache error.log: [thu jun 02 09:09:24.324782 2016] [negotiation:error] [pid 4328:tid 1676] [client 127.0.0.1:4940] ah00690: no acceptable variant: d:/xampp/apache/error/http_not_found.html.var

the laravel.log: local.error: exception 'illuminate\session\tokenmismatchexception' in f:\phpstormprojects\restfulprac\vendor\laravel\framework\src\illuminate\foundation\http\middleware\verifycsrftoken.php:67 stack trace:

if 1 can me ,i'd appreciate it!thanks in advanced!

based on laravel error log have csrf token mismatch. if building api not want use 'web' middleware. middleware group starting session , check csrf token on requests aren't using read (get, head, options) http methods.

by default laravel putting routes in routes.php in route group 'web' middleware applied (if on version >= 5.2.27) when loads them in routeserviceprovider in app\providers.

that start, based on laravel error log.

this may of help: verifycsrftoken called when route api middleware laravel 5.2.35


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo