[Flow] Curl PUT doesn't works
Adriano Fialho
afialho.com at gmail.com
Fri Mar 14 15:02:18 CET 2014
My apologies for not having pasted the complete data.
All others curl methods (POST, DELETE, GET) works fine. Only PUT doesn't.
*My route:*
-
name: 'Contatos de Marketing'
uriPattern: 'rest-api/apimentimarketing/contact/{contact}(/{@action})'
defaults:
'@controller': 'RestAPI\Contact'
'@action': 'index'
*My controller: *(only updateAction above)
namespace Apimenti\Marketing\Controller\RestAPI;
use Apimenti\Marketing\Domain\Model\Contact;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Mvc\Controller\RestController;
/**
* @Flow\Scope("singleton")
* @author Adriano Fialho <adriano at apimenti.com.br>
*/
class ContactController extends RestController {
protected $defaultViewObjectName = 'TYPO3\\Flow\\Mvc\\View\\JsonView';
protected $resourceArgumentName = 'contact';
/**
* @param \Apimenti\Marketing\Domain\Model\Contact $contact
* @Flow\IgnoreValidation("$contact")
* @return void
*/
public function updateAction(Contact $contact) {
try {
$this->contactRepository->update($contact);
$this->response->setStatus(200);
} catch (\Exception $e) {
$this->view->setVariablesToRender(array('response'));
$this->response->setStatus(400);
$this->view->assign('response', array('error' => $e->getMessage()));
}
}
}
--
*Adriano Fialho*
71 8637.3450 - 71 9335.9343
afialho.com - adriano at afialho.com
On Fri, Mar 14, 2014 at 10:42 AM, Carsten Bleicker <carsten at bleicker.de>wrote:
> why do you have identity in your uri and also in body arguments?
> also your controller action seems not to have any annotations wich type of
> is $contact.
> please also show the route.
>
> example:
> /**
> * @param Contact $contact
> */
> public function updateAction(Contact $contact){}
>
>
> example route for your request could be:
> -
> name: 'Artist Rest'
> uriPattern: 'contact/{contact.__identity}
> httpMethods: ['PUT']
> defaults:
> '@package': 'Acme.Foo'
> '@controller': 'Contact'
> '@action': 'list'
> '@format': 'json'
>
> note: route untested
>
>
>
> Am 14.03.2014 um 14:31 schrieb Adriano Fialho <afialho.com at gmail.com>:
>
> > *My request:*
> > curl -X PUT -d "contact[name]=New name&contact[__identity]=12345"
> > http://myservice.com/contact/12345
> >
> > *And my rest controller update action:*
> > public function updateAction($contact){
> > MyRepository->update($contact)
> > }
> >
> >
> >
> > --
> >
> > *Adriano Fialho*
> > 71 8637.3450 - 71 9335.9343
> > afialho.com - adriano at afialho.com
> >
> >
> > On Fri, Mar 14, 2014 at 9:50 AM, Adriano Fialho <afialho.com at gmail.com
> >wrote:
> >
> >> People,
> >>
> >> I tried to do a PUT request with php curl to my Flow RestController,
> but it
> >> doesn't works. The request is executed sucessfully, but the
> updateAction on
> >> my controller can't update my object on repository.
> >>
> >> Do you know anything about that?
> >>
> >> --
> >>
> >> *Adriano Fialho*
> >> 71 8637.3450 - 71 9335.9343
> >> afialho.com - adriano at afialho.com
> >> _______________________________________________
> >> Flow mailing list
> >> Flow at lists.typo3.org
> >> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
> >>
> > _______________________________________________
> > Flow mailing list
> > Flow at lists.typo3.org
> > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>
More information about the Flow
mailing list