diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1be23e4..d70c0ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
 # CHANGELOG
 
 ## Unreleased
+### Fixed
+* Assets with empty or missing files no longer error when trying to get it serialized to string. [#48](https://github.com/contentful/contentful.py/issues/48)
 
 ## v1.12.1
 ### Fixed
diff --git a/contentful/asset.py b/contentful/asset.py
index 90d9ffe..284590b 100644
--- a/contentful/asset.py
+++ b/contentful/asset.py
@@ -30,6 +30,9 @@ class Asset(FieldsResource):
             "//images.contentful.com/spaces/foobar/...?w=120&h=160"
         """
 
+        if not hasattr(self, 'file') or not self.file:
+            return ""
+
         url = self.file['url']
         args = ['{0}={1}'.format(k, v) for k, v in kwargs.items()]
 

Optional linked assets cannot be represented
`Asset.__repr__()` utilises `Asset.url()` which depends on `file` instance attribute.

If the asset is optional and not set, the object cannot be represented: `'contentful.asset.Asset object' has no attribute 'file'`.
diff --git a/tests/asset_test.py b/tests/asset_test.py
index 426b2e2..f0c5635 100644
--- a/tests/asset_test.py
+++ b/tests/asset_test.py
@@ -38,3 +38,50 @@ class AssetTest(TestCase):
         self.assertEqual(asset.url(), '//images.contentful.com/...')
         self.assertEqual(asset.url(w=123), '//images.contentful.com/...?w=123')
         self.assertEqual(str(asset), "<Asset id='foo' url='//images.contentful.com/...'>")
+
+    def test_asset_with_no_file_can_be_serialized_correctly(self):
+        asset = Asset({
+            'sys': {
+                'type': 'Asset',
+                'id': 'foo',
+                'createdAt': '2016-12-01T11:39:20.257859',
+                'updatedAt': '2016-12-01T11:39:20.257859',
+                'space': {
+                    'sys': {
+                        'type': 'Link',
+                        'linkType': 'Space',
+                        'id': 'foo'
+                    }
+                }
+            },
+            'fields': {
+                'title': 'Awesome Pic',
+                'description': 'A picture of something'
+            }
+        })
+
+        self.assertEqual(str(asset), "<Asset id='foo' url=''>")
+
+    def test_asset_with_empty_file_can_be_serialized_correctly(self):
+        asset = Asset({
+            'sys': {
+                'type': 'Asset',
+                'id': 'foo',
+                'createdAt': '2016-12-01T11:39:20.257859',
+                'updatedAt': '2016-12-01T11:39:20.257859',
+                'space': {
+                    'sys': {
+                        'type': 'Link',
+                        'linkType': 'Space',
+                        'id': 'foo'
+                    }
+                }
+            },
+            'fields': {
+                'title': 'Awesome Pic',
+                'description': 'A picture of something',
+                'file': {}
+            }
+        })
+
+        self.assertEqual(str(asset), "<Asset id='foo' url=''>")

pip install -e .
parse_log_pytest
requirements.txt
pytest vcrpy requests-mock
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
-e git+https://github.com/contentful/contentful.py.git@971173ab4d0391889dd90d127f2cff94f668cf17#egg=contentful
coverage==4.3.4
docutils==0.18.1
flake8==3.3.0
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
iniconfig==1.1.1
Jinja2==3.0.3
MarkupSafe==2.0.1
mccabe==0.6.1
packaging==21.3
pluggy==0.13.1
py==1.11.0
pycodestyle==2.3.1
pyflakes==1.5.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.6.0
pytz==2025.2
PyYAML==6.0.1
requests==2.27.1
requests-mock==1.5.2
six==1.17.0
snowballstemmer==2.2.0
Sphinx==1.6.3
sphinxcontrib-websupport==1.0.1
tomli==1.2.3
tox==2.5.0
typing_extensions==4.1.1
urllib3==1.26.20
vcrpy==1.10.3
virtualenv==15.1.0
wrapt==1.16.0
zipp==3.6.0

name: contentful.py
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - coverage==4.3.4
      - docutils==0.18.1
      - flake8==3.3.0
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - markupsafe==2.0.1
      - mccabe==0.6.1
      - packaging==21.3
      - pluggy==0.13.1
      - py==1.11.0
      - pycodestyle==2.3.1
      - pyflakes==1.5.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-dateutil==2.6.0
      - pytz==2025.2
      - pyyaml==6.0.1
      - requests==2.27.1
      - requests-mock==1.5.2
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==1.6.3
      - sphinxcontrib-websupport==1.0.1
      - tomli==1.2.3
      - tox==2.5.0
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - vcrpy==1.10.3
      - virtualenv==15.1.0
      - wrapt==1.16.0
      - zipp==3.6.0
prefix: /opt/conda/envs/contentful.py

tests/asset_test.py::AssetTest::test_asset_with_empty_file_can_be_serialized_correctly tests/asset_test.py::AssetTest::test_asset_with_no_file_can_be_serialized_correctly
tests/asset_test.py::AssetTest::test_asset
contentful/asset.py CHANGELOG.md
contentful/asset.py CHANGELOG.md