RESTful-Drupal / restful

RESTful best practices for Drupal
https://drupal.org/project/restful
419 stars 173 forks source link

Create Node with Multiple FieldCollection Item #1037

Open julienperrault opened 6 years ago

julienperrault commented 6 years ago

Hi, I want to create a node through the POST route with a proprety named "box".

        $public_fields['box'] = array(
            'property' => 'box',
        );

Box is a FieldCollection. So when i send :

{
 "abc": "def",
 "box": [
        {
            "qty": "2180",
            "item": "potato"
        },
        {
            "qty": "2821",
            "item": "tomato"
        }
]
}

I looking for a node linked with those 2 new items.

When i look in SQL log i found this :

INSERT INTO field_data_box (entity_type, entity_id, revision_id, bundle, delta, language, box_value, box_revision_id) VALUES ('node', '15068', '23455', 'testNode', '0', 'und', '2187', '2180', NULL), ('node', '15068', '23455', 'company_profile', '1', 'und', '2180', '2821', NULL)

So he doesn't create each field collection item. He just try to link with qty values.

charlie-rushton commented 4 years ago

@julienperrault I know this was a long time, but by ay chance did you manage to solve this one?

julienperrault commented 4 years ago

@charlie-rushton Oh indeed, I forgot to close the ticket. I found a tricky way to do it. First I create a route for each multiple FieldCollection ressources.

During execution:

The big problem is the infinite creation/deletion of this system which leads to an excessive increase in the primary key of the elements.