How to create a content with files attached through API

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

I’m able to create new content with REST API but I’m not sure how to attach a file/image to it.

Expected behavior

Minimal reproduction of the problem

I’m using Python requests with the REST API (code snippet)

import requests
          'Content-Type': 'application/json', #this should be multipart/form-data once I add a file.
          'Authorization': 'Bearer ' + token

payload = json.dumps({
                        "dni": {
                            "iv": row['dni']
                        "nombres": {
                            "iv": row['nombres']

response = + "/api/content/atlas/padron/?publish=true", headers=headers, data=payload, verify=False)


{‘total’: 1, ‘items’: [{‘id’: ‘da05bdaf-1ab4-4878-a80e-bab608e8c4f9’, ‘createdBy’: ‘subject:6081f499800b8c7454f0fd73’, ‘lastModifiedBy’: ‘subject:6081f499800b8c7454f0fd73’, ‘data’: {‘dni’: {‘iv’: None}, ‘nombres’: {‘iv’: None}, ‘created’: ‘2021-04-23T03:30:20Z’, ‘lastModified’: ‘2021-04-23T03:30:20Z’, ‘status’: ‘Published’, ‘statusColor’: ‘#4bb958’, ‘schemaName’: ‘padron’, ‘schemaDisplayName’: ‘padron’, ‘version’: 1, ‘_links’: {‘self’: {‘href’: ‘/api/content/atlas/padron/da05bdaf-1ab4-4878-a80e-bab608e8c4f9’, ‘method’: ‘GET’}, ‘previous’: {‘href’: ‘/api/content/atlas/padron/da05bdaf-1ab4-4878-a80e-bab608e8c4f9/0’, ‘method’: ‘GET’}, ‘draft/create’: {‘href’: ‘/api/content/atlas/padron/da05bdaf-1ab4-4878-a80e-bab608e8c4f9/draft’, ‘method’: ‘POST’}, ‘delete’: {‘href’: ‘/api/content/atlas/padron/da05bdaf-1ab4-4878-a80e-bab608e8c4f9’, ‘method’: ‘DELETE’}}}], ‘statuses’: [{‘status’: ‘Archived’, ‘color’: ‘#eb3142’}, {‘status’: ‘Draft’, ‘color’: ‘#8091a5’}, {‘status’: ‘Published’, ‘color’: ‘#4bb958’}], ‘_links’: {‘self’: {‘href’: ‘/api/content/atlas/padron’, ‘method’: ‘GET’}, ‘create’: {‘href’: ‘/api/content/atlas/padron’, ‘method’: ‘POST’}, ‘create/publish’: {‘href’: ‘/api/content/atlas/padron?publish=True’, ‘method’: ‘POST’}}}

Now I add a “photo”(asset field) and the Swagger API Docs specification says that “photo” field is:

“photo”: {

Which is not clear for me how to handle it for a correct image upload related to that content row.

Hope it makes sense to you. Thanks in advance Sebastian!


  • [ X ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]


  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge


When you upload the asset you get the asset object back. You take the ID and assign as a an array to the asset field:

Thanks a lot Sebastian, sorry for my bad research!

1 Like