Understanding the Issue
When attempting to delete an asset, the absence of an error message, but a result string indicating an error 506, suggests that the URL used for the DELETE call is incorrect.
Root Cause and Solution
The root cause of the issue is an incorrectly formatted URL for the DELETE request. The correct URL should point to the specific asset endpoint.
To fix this, ensure that the URL is correctly constructed by concatenating the rest_instance_url with the asset endpoint and the asset ID. For example, in SSJS, this can be achieved as follows:
deleteAsset.ssjs
var rest_instance_url = 'https://' + et_subdomain + '.rest.marketingcloudapis.com/'; var assetId = '135006'; var url = rest_instance_url + 'asset/v1/content/assets/' + assetId; // Perform the DELETE request using the constructed URL
Implementation Steps
Checklist for Deleting Assets via REST API
- Ensure you have the correct asset ID.
- Construct the REST endpoint URL by concatenating
rest_instance_urlwith the asset endpoint and asset ID. - Use the constructed URL to make a DELETE request.
- Verify that the asset has been successfully deleted by checking its status or attempting to retrieve it.
- Handle any potential errors or exceptions that may occur during the deletion process.
Frequently Asked Questions
What is the correct endpoint for deleting assets?
The correct endpoint for deleting assets is asset/v1/content/assets/{assetId}.
How do I handle errors during asset deletion?
Handle errors by checking the response status code and message, and implement retry logic if necessary.
Can I delete multiple assets at once?
No, the REST API requires a separate DELETE request for each asset.
What permissions are required to delete assets?
You need to have the necessary permissions to manage assets within your Marketing Cloud account.
Need help shipping this in production?
Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.