我是restful api的新手,我遇到了一个问题,问题是:当我用delete方法请求destroy并用post方法存储时,两者都会返回500错误。但我用get方法请求索引和显示,都可以。问题是什么?这是我的代码和要求:
删除 http://***.com/RestfulPrac/public/customers/10000001
获取 http://***.com/RestfulPrac/public/customers/10000001
发布 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');
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, like Gecko) Chrome/50.0.2661.102野生动物园/537.36"
apache error.log:[Thu Jun 02 09:09:24.324782 2016] [negotiation:error] [pid 4328:tid 1676] [client 127.0.0.1:4940] AH00690:没有可接受的变体:D:/XAMPP/apache/错误/HTTP_NOT_FOUND.html.var
laravel.log: local.ERROR: exception 'Illuminate\Session\TokenMismatchException' in F:\PhpstormProjects\RestfulPrac\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php:67 堆栈跟踪:
如果有人可以帮助我,我将不胜感激!在此先感谢!