php - FOSRestBundle - POST went fine, but when use PUT/PATCH $request is null -
php - FOSRestBundle - POST went fine, but when use PUT/PATCH $request is null -
i next tutorial http://welcometothebundle.com/symfony2-rest-api-the-best-way-part-3/ , i've added new entity, author.
using get, post , delete goes expected, when using set or patch result:
[{"message":"an exception occurred while executing 'insert author (id, name, password) values (?, ?, ?)' params [16, null, null]: \n\nsqlstate[23502]: not null violation: (...)
this header receive:
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
this php code
public function putauthoraction(request $request, $id) { seek { if (!($author = $this->container->get('acme_blog.author.handler')->get($id))) { $statuscode = codes::http_created; $author = $this->container->get('acme_blog.author.handler')->post( $request->request->all() ); } else { $statuscode = codes::http_no_content; $author = $this->container->get('acme_blog.author.handler')->put( $author, $request->request->all() ); } $routeoptions = array( 'id' => $author->getid(), '_format' => $request->get('_format'), ); homecoming $this->routeredirectview('get_author', $routeoptions, $statuscode); } grab (invalidformexception $exception) { homecoming $exception->getform(); } }
and inserted a
return $request->request->all();
before seek block within putauthoraction , empty array response...
does had similar issue?
i tried fosrestbundle post/put [create new/update entity] not read request correctly have no success..
i'm using postman extension in chromium test ... (and sorry english, it's not primary language)
php symfony2 fosrestbundle
Comments
Post a Comment