mrevutskyi / flask-restless-ng

A Flask extension for creating simple ReSTful JSON APIs from SQLAlchemy models.
https://flask-restless-ng.readthedocs.io
Other
64 stars 11 forks source link

POST on Relationship return 204, but the database doesn't have any created relationship. #13

Closed sharky98 closed 3 years ago

sharky98 commented 3 years ago

I think I have experienced the something similar #1. Basically I have a many-to-many relationship between Item A and Item C. I create Item C and relation to existing Item A with jquery.ajax() (note that I am seeing the same behavior with Postman). Since there is no (documented?) way to assign many-to-many relationship at creation (there is no attribute with the ID relationship), the way I do it is I create the Item C first POST /api/c_item, then when it's successful, I create the relationship POST /api/c_item/{newlyCreatedId}/relationships/a_items. My posted data is in the following format.

{
data: [
    {
      type: "a_item",
      id: 1
    },
    {
      type: "a_item",
      id: 2
    }
  ]
}

You can see a replication of the issue in the linked repository below.

mrevutskyi commented 3 years ago

Should be fixed in v1.0.2