def update_entry(contentful_id, car_id):
entry = environment.entries().find(contentful_id)
entry.fields['featuredImage'] = {
'en-US': {
'sys': {
'type': 'Link',
'linkType': 'Asset',
'id': str(car_id) + '_featured_image'
}
}
}
time.sleep(10)
entry.save()
print("entry updated")
I used this code and I couldn't make it.
I have to update a field featuredImage which is a link to the asset. An asset's link is like I created it (str(car_id) + '_featured_image').
My main plan was to retrieve an entry from Contentful using ID on Contentful, add a link to the asset field, and save it. It is not working.
Also, should I publish the entry again?
def update_entry(contentful_id, assedId):
entry = environment.entries().find(contentful_id)
fields = entry.fields()
fields['featuredImage'] = {
'sys': {
'type': 'Link',
'linkType': 'Asset',
'id': assedId
}
}
entry.update()
entry.save()
entry.publish()
time.sleep(2)
Okay so this is how I updated and published the entry in Contentful