OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Update custom entity data using API PUT

This topic contains 7 replies, has 2 voices, and was last updated by  kelton23om 9 years, 8 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #33408

    kelton23om
    Participant

    Hi oro’s guys,
    I have an issues when i try to update my custom entity using a REST API.

    I create an entity with my own controller, my own Form type and handler.. etc..
    To do that, i duplicate(almost) an existing case in the OroPlatform..

    My problem seems to appear during the processForm, where the form submit do not hydrate data from the Request.

    Do you have any idea where that is come from ?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #33409

    Alexandr Smaga
    Participant

    Hello @kelton23om!
    Could you please provide more details? Are you talking about REST api ? Are you working with named form ?

    #33410

    kelton23om
    Participant

    Hi,

    Yes i talk about a REST API.. i try to build my own REST API to expose my Own webservices dedicates to my Custom entity.
    To do that, i decided to follow an example as in the NotesBundle.. and it’s work pretty well for “delete” and “get” web services, but i encouter a problem when i try to PUT or POST some data.
    After some explorations i realize that the problem come from the Form process method,
    the submit method to be more precise who did not do the job!

    I don’t really known why, but the model Object is never hydrated by the request data..
    whereas if i trace my request i can see form data in the parameter bag.

    i expect that explains a bit more the situation.

    thanks again to spend a bit of your time answer my questions :)

    #33411

    Alexandr Smaga
    Participant

    Can you share $this->form->getName(), var_dump(array_keys($this->form->all())) and var_dump($this->request->request->all()); ?

    #33412

    kelton23om
    Participant

    Hi, of course here it is:

    $this->form->getName()

    var_dump(array_keys($this->form->all()));

    var_dump($this->request->request->all());

    #33413

    Alexandr Smaga
    Participant

    Hello.

    Please try to use

    #33414

    kelton23om
    Participant

    Hi,

    I’m not sure to do the right thing, but i get a 404 error !!!

    :/

    #33415

    kelton23om
    Participant

    I found from where my issue came…

    It’s because of the form service declaration and the way the RestController manage the request.

    in “Oro\Bundle\SoapBundle\Controller\Api\Rest\RestController” the “fixRequestAttributes” method handle the parameters from Request.

    the problem is that this method treats the request as a “GET” if the “Form” contains a name.

    And of course in my case i put a name in my form declaration, in the “service.yml”:

    So i just need to remove the name from the arguments like this:

    that’s it :)

    I’m not really sure about the meaning of the fixRequestAttributes method but it seems to have a quite strange behavior in my opinion!

    thanks again!! keep going your good work

Viewing 7 replies - 1 through 7 (of 7 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top