Reputation: 603
is it possible to override the entries in a many-to-many association via the admin API? I tried it with a basic update (PATCH) request and instead of overriding the association it just adds the new ones.
Before Update:
[GET] {apiBasePath}/product/91d7e5d1e77b48ae957d90f9a5210465
{
"data": {
"id": "91d7e5d1e77b48ae957d90f9a5210465",
"properties": [
{
"id": "4a893ae509cc42ce9084a2ac55753bd6"
}
]
}
}
Update:
[PATCH] {apiBasePath}/product/91d7e5d1e77b48ae957d90f9a5210465
{
"id": "91d7e5d1e77b48ae957d90f9a5210465",
"properties": [
{
"id": "1e2569aa85c74f8baa3a85978b42a5ec"
}
]
}
After Update:
[GET] {apiBasePath}/product/91d7e5d1e77b48ae957d90f9a5210465
{
"data": {
"id": "91d7e5d1e77b48ae957d90f9a5210465",
"properties": [
{
"id": "4a893ae509cc42ce9084a2ac55753bd6",
"id": "1e2569aa85c74f8baa3a85978b42a5ec"
}
]
}
}
Expected Result:
[GET] {apiBasePath}/product/91d7e5d1e77b48ae957d90f9a5210465
{
"data": {
"id": "91d7e5d1e77b48ae957d90f9a5210465",
"properties": [
{
"id": "1e2569aa85c74f8baa3a85978b42a5ec"
}
]
}
}
Upvotes: 1
Views: 308
Reputation: 13161
It's by design that setting associations is accumulative. If you need to remove associated data refer to the documentation.
Upvotes: 1