Laravel 5请求值为空


Laravel 5 request value null

这是我的控制器中的代码:

  public function postExample(Request $request) {
         $id = $request->input('subjectId');
         Log::warning('id is:' . $id . ",and request:" . $request);

问题是变量$id为null(空字符串)。这是日志:

 id is:,and request:POST      ....
 Accept:          application/json, text/plain, */*
 Accept-Encoding: gzip, deflate
 Content-Length:  19
 Content-Type:    application/x-www-form-urlencoded
         . . . .
 {"subjectId":"13"}  

我试过用:$id = $request->get('subjectId');,它是一样的。

编辑:我用angularjs发帖,这是代码:

            $http({
            method: 'POST',
            url: '/api/profesor/setStrukturaPredmeta',
            data:  { subjectId: '13' },
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
            }).then(function successCallback(response) {
                $("body").html(JSON.stringify(response));
            }, function errorCallback(response) {
                $("body").html("error: "+JSON.stringify(response));
            });

我通过删除angularjs控制器中的标头来解决这个问题,但我不明白为什么在包含标头时它不起作用。