RestAPI custom model async operation in Oro

Viewed 43

I created model AcmeBundle\Api\Model\AcmeLineItem with few fields and configured it in the config/oro/api.yml file.

api:
  entity_aliases:
    AcmeBundle\Api\Model\AcmeLineItem:
      alias:        acme
      plural_alias: acme
  entities:
    AcmeBundle\Api\Model\AcmeLineItem:
      fields:
        name:
          data_type: string
          form_options:
            constraints:
              - NotBlank: ~
      actions:
        create: true
        update_list: true
        

Fields available in the processor for create action and can be processed in a needed way by it.

- { name: oro.api.processor, action: create, group: save_data, class: AcmeBundle\Api\Model\AcmeLineItem }

But the method required body structure in meta key.

{
  "meta": {
    "name": "acme"
  }
}

Based on this, it's hard to find out how to approach the update_list action.

1 Answers

It is required to specify an entity identifier (id). To do that, set identifier_field_names option for AcmeBundle\Api\Model\AcmeLineItem in the api.yml file.

identifier_field_names string[] - The names of identifier fields of the entity. Use this option to override names set in a configuration file (for the API resource that are not based on ORM entity) or retrieved from an entity metadata (for ORM entities). This option is helpful when you do not want to use the primary key as an entity identifier in the API.

Full API Configuration Reference: https://doc.oroinc.com/backend/api/configuration/#web-api-entities-config

Related