AEM Assets API: DUPLICATE_URLS error when importing assets with the same source URL
This article describes how to resolve the DUPLICATE_URLS error that occurs when importing multiple assets with the same source URL but different filenames and metadata in a single batch request using the AEM Assets API.
Description description
Environment
Adobe Experience Manager (AEM) Assets (all versions)
Symptoms
- When submitting a batch import request to the AEM Assets
/adobe/assets/import/fromUrlAPI endpoint, if two or more files in the same request reference the sameurlvalue (source URL), but have differentfileNamevalues and different metadata, the API returns a 400 Bad Request with error codeDUPLICATE_URLS. - The error occurs even when the
fileNameand asset metadata are unique for each entry. - The expected behavior is to allow the same source URL to be ingested as separate assets with unique filenames and metadata in the same folder.
Cause
The AEM Assets batch import API validates uniqueness based on the source URL within a single batch request. Multiple entries referencing the same URL are rejected, regardless of differing filenames or metadata. This isn’t configurable in current releases.
Resolution resolution
Follow the steps below to resolve the issue:
-
Split the batch into separate import requests. Instead of including multiple files with the same source URL in a single
/fromUrlbatch request, submit each file as a separate API call. These calls can be issued in parallel, as there’s no ordering dependency when targeting differentfileNamevalues in the same folder. -
Alternatively, use the Assets HTTP API COPY operation:
-
Ingest the asset once using
/fromUrl. -
Use the Assets HTTP API COPY operation to duplicate the ingested asset to a new
fileNamein the same folder. -
Update the metadata on the copied asset, as needed. This avoids a second fetch of the binary and bypasses the
DUPLICATE_URLScheck.
-
After following these steps, verify that each asset appears in the target folder with the correct filename and metadata.