Replaces references in a specified field of a specified data item.
This endpoint replaces the existing reference or references contained in the field specified in referringItemFieldName
within the data item specified in referringItemId
.
The endpoint removes existing references and in their place it adds references to the items specified in newReferencedItemIds
.
Note: If you pass an empty array in newReferencedItemIds
, all existing references are removed.
You can only call this method when authenticated as a Wix app or Wix user identity.
ID of the collection containing the referring item.
Field containing references in the referring item.
ID of the referring item.
List of new referenced item IDs to replace the existing ones.
Updated references.
curl -X POST \
'https://www.wixapis.com/wix-data/v2/items/replace-references' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-d '{
"dataCollectionId": "albums",
"referringItemFieldName": "songs",
"referringItemId": "37de298e-026d-4b2e-b87f-fbec11d53105",
"newReferencedItemIds": ["aafeaaf4-6192-4cc2-a79b-97ce0f1b3646"]
}'
{
"dataItemReferences": [
{
"referringItemFieldName": "songs",
"referringItemId": "37de298e-026d-4b2e-b87f-fbec11d53105",
"referencedItemId": "aafeaaf4-6192-4cc2-a79b-97ce0f1b3646"
}
]
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.