Sometimes (I cannot detect the conditions) asset-field in Entry have no attached file, so asset.utl() return empty string.
For example
import contentful
client = contentful.Client(
Config.CONTENTFUL_SPACE_ID,
Config.CONTENTFUL_PREVIEW_ACCESS_TOKEN,
api_url="preview.contentful.com")
# first approach
entry = client.entry('xyz', {'locale': '*'})
asset = entry.fields('en')['some_image'] # here asset is <Asset id='xyz' url=''>
asset.url() # this one returns empty string
but if I create the same asset directly, .url() works fine
# second approach
client.asset('xyz') # here asset is <Asset id='xyz' url='//images.ctfassets.net/...'>
First approach definitely worked before and it works now (at least sometimes), so I really cannot understand what is going on.
UPD:
The reason was that we renamed default locale en-US > en and after that entries which were requested with locale="*" had empty Assets. So we had to pass our new default locale to the Client class.
Sometimes (I cannot detect the conditions) asset-field in Entry have no attached file, so asset.utl() return empty string.
For example
but if I create the same asset directly, .url() works fine
First approach definitely worked before and it works now (at least sometimes), so I really cannot understand what is going on.
UPD: The reason was that we renamed default locale en-US > en and after that entries which were requested with locale="*" had empty Assets. So we had to pass our new default locale to the Client class.