小编Ale*_*sse的帖子

FOSRestBundle - POST 运行正常,但使用 PUT/PATCH $request 时为空

我正在关注本教程http://welcometothebundle.com/symfony2-rest-api-the-best-way-part-3/然后我添加了一个新实体 Author。

使用 GET、POST 和 DELETE 一切都按预期进行,但是在使用 PUT 或 PATCH 时,我得到以下结果:

[{"message":"An exception occurred while executing 'INSERT INTO Author 
(id, name, password) VALUES (?, ?, ?)' with params [16, null, null]:
\n\nSQLSTATE[23502]: Not null violation: (...)
Run Code Online (Sandbox Code Playgroud)

这是我收到的标题:

Allow ?GET, PUT, PATCH, DELETE
Cache-Control ?no-cache
Connection ?keep-alive
Content-Type ?application/json
Date ?Tue, 28 Oct 2014 14:30:10 GMT
Server ?nginx/1.1.19
Transfer-Encoding ?chunked
X-Debug-Token ?6d899c
X-Debug-Token-Link ?/api/_profiler/6d899c
X-Powered-By ?PHP/5.4.33-2+deb.sury.org~precise+1
Run Code Online (Sandbox Code Playgroud)

这是我的 PHP 代码

public function putAuthorAction(Request $request, $id)
{
    try {
        if (!($author …
Run Code Online (Sandbox Code Playgroud)

php symfony fosrestbundle

5
推荐指数
0
解决办法
1203
查看次数

标签 统计

fosrestbundle ×1

php ×1

symfony ×1