Skip to main content

How to add new media to your DAM via the Quable API with an HTTP URL as source file?

Lucien Berkani avatar
Written by Lucien Berkani
Updated this week

You have to make two API calls:

the first one to load your media file in the Quable storage. The second one is to create your asset in your DAM

Upload your media file:

Here is an example with Python, which calls the [POST] /api/files API:

import requests

url = "{{host}}/api/files"

payload = json.dumps({
"fileType": "asset",
"remotePath": "https://www.mydomain.com/myfile.jpg"
})

headers = {
'Accept': 'application/ld+json',
'Authorization': 'Bearer {{pim_token}}',
'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

The JSON response returns an "id" :

{
"id": "__ID__",
"name": "your_file_name.jpg",
"location": {
"container": "your_pim_instance",
"filename": "98c0640d-dfbe-429f-9802-28f9ad7f9d54"
},
"metadatas": {
"mime_type": "image/jpg"
},
"status": "available",
"type": "asset",
"dateCreated": "2023-04-26T14:41:12+00:00",
"dateModified": "2023-04-26T14:41:12+00:00"
}

Associate this file with an new asset in Quable DAM:

You then use this ID to create an asset record in the Quable DAM, as in the example below:

import requests
import json

url = "{{host}}/api/assets"

payload = json.dumps({
"id": "sweat-capuche-bleu",
"file": {
"id": "__ID__"
},
"classification": {
"id": "dam_sort"
},
"attributes": {
"media_nom_photographe": {
"fr_FR": "John Doe"
}
}
})
headers = {
'Authorization': 'Bearer {{pim_token}}',
'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
Did this answer your question?