Hello.
I’m trying to create entries in python, and map my data to the content model I have created.
My product
entry contains a media
field, that accepts one more more images. How do I create entries that add these images? Are images assets
? Do I create these assets first, and then pass on their IDs to the entry somehow?
This is the straight forward method I have tried, that do not work:
# auth + fetched the space object ... then:
entry_attributes = {
'content_type_id': 'product',
'fields': {
'product_name': {
'nb-NO': 'Nice product'
},
'description': {
'nb-NO': 'The best product that money cannot buy.'
},
... more normal fields, then ...
'images': {
'items': {
'nb-NO': 'www.pictu.re/loc2.jpg',
'nb-NO': 'www.pictu.re/loc.jpg'
}
}
# and create entry from this dict:
new_entry_id = None # Use `None` if you want the API to autogenerate the ID
new_entry = space.entries().create(
new_entry_id,
entry_attributes
)
print("Did I create a thing now?")
This does not work. Although the JSON preview of the content model looks to me like it could work.
Also: just pasing the URLs to the images as a list (the media field is of type Array, according to the same JSON preview) does not work:
JSON preview:
{
"id": "images",
"name": "images",
"type": "Array",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [],
"linkType": "Asset"
}
alternative dict struture for list
'images': {
'items': [ 'www.pictu.re/loc2.jpg', 'www.pictu.re/loc.jpg']
}
How should this be done properly? How do I pass along images with a new entry?