POST

Replace Data Item References


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.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage All Data Resources
Manage Data Items
Write Data Items
Learn more about app permissions.
Endpoint
POST
https://www.wixapis.com/wix-data/v2/items/replace-references

Body Params
dataCollectionIdstringRequired

ID of the collection containing the referring item.


referringItemFieldNamestringRequired

Field containing references in the referring item.


referringItemIdstringRequired

ID of the referring item.


newReferencedItemIdsArray <string>

List of new referenced item IDs to replace the existing ones.

Response Object
dataItemReferencesArray <DataItemReference>

Updated references.

Replace existing references with new references
Request
cURL
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"] }'
Response
JSON
{ "dataItemReferences": [ { "referringItemFieldName": "songs", "referringItemId": "37de298e-026d-4b2e-b87f-fbec11d53105", "referencedItemId": "aafeaaf4-6192-4cc2-a79b-97ce0f1b3646" } ] }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?