Search code examples
orocrm

OroCRM How to expose and extended field to the api?


After adding a Status select to the CalendarEvent. I wish to have it returned in the /api/rest/latest/calendarevents results but it does not appear there.

How do I get new fields to be returned as part of the api results?


Solution

  • "/api/rest/latest/" is a deprecated plain API that is not supported anymore.

    It's recommended to use a new JSON API. You can find documentation on it in "/api/doc". Calendar events are not exposed by default to this API, but's it's can be enabled with the simple configuration:

    1. Create a file in a bundle Resources/config/oro/api.yml with below content

      api:
        entities:
          Oro\Bundle\CalendarBundle\Entity\CalendarEvent: ~
      
    2. Then run the command

      php bin/console oro:api:doc:cache:clear
      
    3. Now you can go to "api/doc" and find there "calendarevents".

    As a result, you will have new API endpoints for calendar events and these endpoints include all the entity fields, including extended select fields.

    For more details on using and extending REST API, please follow the documentation.