# Unable to serialize type: \<class 'elasticsearch\_dsl.document.InnerDoc'

**URL:** <https://discuss.elastic.co/t/unable-to-serialize-type-class-elasticsearch-dsl-document-innerdoc/201505>\
**Category:** Elasticsearch\
**Created:** [September 28, 2019, 7:04pm UTC](https://discuss.elastic.co/t/unable-to-serialize-type-class-elasticsearch-dsl-document-innerdoc/201505 "2019-09-28T19:04:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![grant\_donovan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grant_donovan/32/42314_2.png) [@grant\_donovan](https://discuss.elastic.co/u/grant_donovan)\
**Post date:** [September 28, 2019, 7:04pm UTC](https://discuss.elastic.co/t/unable-to-serialize-type-class-elasticsearch-dsl-document-innerdoc/201505/1 "2019-09-28T19:04:49Z")

</div>

I am just in the process of moving from an old version of Elasticsearch to 6.8. All is going well except that I am getting the above error when attempting to update\add a record.

This is my code

```auto
if not isinstance(existing_es_doc, dict):
    esdoc_clean = existing_es_doc.to_dict()
else:
    esdoc_clean = existing_es_doc

r = es.update(index=index, doc_type='product_set_change_log', id=self.isbn_id + '-%s' % self.api_id,
                          body={'doc': esdoc_clean, 'doc_as_upsert': True})

```

The full error is

```auto
TypeError("Unable to serialize {'territories': [], 'salesRightsType': u'01'} (type: <class 'elasticsearch_dsl.document.InnerDoc'>)",))

```

The type that it is referring too is InnerDoc, I can see that in the esdoc\_clean dict.

As part of the migration this import was no longer valid

```auto
from elasticsearch_dsl import InnerObjectWrapper

```

I get my body from another service, so I can't modify that

This worked on the older Elasticsearch version

Has anyone seen this before?

Thanks

Grant

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 26, 2019, 7:12pm UTC](https://discuss.elastic.co/t/unable-to-serialize-type-class-elasticsearch-dsl-document-innerdoc/201505/2 "2019-10-26T19:12:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
