Inserts a reference in the specified field in an item in a collection.
A reference in the dataItemReference
field specifies a referring item's ID, the field in which to insert the reference, and the ID of the referenced item.
You can only call this method when authenticated as a Wix app or Wix user identity.
ID of the collection in which to insert the reference.
Reference to insert
Additional parameters specific to the Wix app collection you are querying.
When querying the Wix Stores Products collection, pass the following optional parameters:
includeHiddenProducts
: Whether to include hidden products in the response. Default: false
.includeVariants
: Whether to include product variants in the query. Default: false
.Inserted reference.
curl -X POST \
'https://www.wixapis.com/wix-data/v2/items/insert-reference' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-d '{
"dataCollectionId": "albums",
"dataItemReference": {
"referringItemFieldName": "songs",
"referringItemId": "37de298e-026d-4b2e-b87f-fbec11d53105",
"referencedItemId": "aafeaaf4-6192-4cc2-a79b-97ce0f1b3646"
}
}'
{
"dataItemReference": {
"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.