OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions REST API for custom entity

This topic contains 2 replies, has 2 voices, and was last updated by  manuel.distefano 7 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
  • #34218

    manuel.distefano
    Participant

    Hello everyone,

    i’m using oro platform and i add a custom Entity (Alumnus) to my project. It’s a “complex” entity, infact it have a relationship (many-to-one) with others custom entities (e.g. Expertise).

    I’m able to create an Alumnus via web, now i’m try to create it via API. I add a REST API (GET – POST – PUT), and i’m able to create an Alumnus. But when i add an array of “Expertises” to my json i get an error.

    I send my request with another php application. My data is in array and i use json_encode before sent it.

    Some code (as us can see i’m using “oro_collection” to add Expertise to Alumnus):

    My Form Type:

    My Entity (Doctrine configuration it’s by yml):

    My json:

    Can someone help me or get me some documentation?

    Tnx

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #34219

    Yurii Muratov
    Participant

    Hi, @manuel-distefano.

    I think that you sent incorrect data for expertises field.

    You should send an array with id’s for this field.

    Please test request with data like:

    Where 1 is id for some record form Expertise

    #34220

    manuel.distefano
    Participant

    Hello Yurii,

    yes that was one problem. In any case i solved it by change oro_collection to collection.

    Need oro_collection type a particular structure in json? I’m just curious at the moment :)

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

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

Back to top