[Flow] How does RestController update work under the hood?
Robert Berghegger
r_berghegger at web.de
Fri Aug 22 10:15:10 CEST 2014
Hello,
i once had the same problem.
Bastian Waidelich gave me a good explanation back then:
http://forum.typo3.org/index.php?t=msg&th=199770&goto=696886&#msg_696886
Please try to configure an object-RoutePart for your 'Api-Article POST'
Configuration in your Routes.yaml file.
It should look like this:
....
-
name: 'Api - Article POST'
uriPattern: 'api/article/{article}'
defaults:
'@package': 'Project.Api'
'@controller': 'Article'
'@action': 'index'
'@format': 'json'
routeParts:
'article':
objectType: 'Project\Api\Domain\Model\Article'
I hope this helps to solve your problem.
Kind regards,
Robert
Am 21.08.2014 13:25, schrieb Max Mustermann:
> Hi all,
>
> i have a RestController which only has the minimum needed methods
> createAction, listAction, showAction, updateAction, deleteAction.
>
> My problem is the updateAction.
> If i call the controller like
> PUT myflow.local/api/article/SOMEARTICLEID
> including http body like
> name=newarticlename&price=10.00
>
> the updateAction gets called, but the argument of the udpateAction
> contains the (old) data from the database.
> so if i call articleRepository->update($article); it doesnt change
> anything, cause $article contains old data.
>
> i also tried http body like
> article[name]=newarticlename&article[price]=10.00
> which doesnt work either
>
> my questions are:
> at which line in the typo3.flow package should the PUT http body be
> merged into the entity?
> how should the http PUT request should really look like? i found a few
> examples, but everyone seems to do it different.
> some use {article.__identity} in the route others dont. some use
> article[] in the body, others dont.
>
> as a note: every action of my article restcontroller works, except
> update which gets called with the correct entity i wanna update,
> but without the new data which shall change - so i dont assume a
> routing problem or such.
>
> my route looks like this:
> -
> name: 'Api - article'
> uriPattern: 'api/article'
> defaults:
> '@package': 'Project.Api'
> '@controller': 'Article'
> '@action': 'index'
> '@format': 'json'
> -
> name: 'Api - Article POST'
> uriPattern: 'api/article/{article}'
> defaults:
> '@package': 'Project.Api'
> '@controller': 'Article'
> '@action': 'index'
> '@format': 'json'
>
>
> thanks for any help
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
More information about the Flow
mailing list