# Upload data via python bulk helper caused error

**URL:** <https://discuss.elastic.co/t/upload-data-via-python-bulk-helper-caused-error/48205>\
**Category:** Elasticsearch\
**Created:** [April 22, 2016, 8:30pm UTC](https://discuss.elastic.co/t/upload-data-via-python-bulk-helper-caused-error/48205 "2016-04-22T20:30:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignaqui](https://avatars.discourse-cdn.com/v4/letter/i/c89c15/32.png) [@ignaqui](https://discuss.elastic.co/u/ignaqui)\
**Post date:** [April 22, 2016, 8:30pm UTC](https://discuss.elastic.co/t/upload-data-via-python-bulk-helper-caused-error/48205/1 "2016-04-22T20:30:04Z")

</div>

Cluster ID: f0a801

Hello,

We are trying to push data to dynamically created indices. Using python helper ([http://elasticsearch-py.readthedocs.org/en/master/helpers.html](http://elasticsearch-py.readthedocs.org/en/master/helpers.html)), we tried to upload data in two following formats:

Format 1: {command n}, {data n}, {command n+1}, {data n+1}, i.e.,  
`{"create":{"_index":"current_index","_type":"prod"}}, {json.dumps(X)}`

Format 2:  
`{"_op_type":"create","_index":"current_index","_type":"prod","_source": json.dumps(X)}`

Iterable variables have been created out of above data and fed into helpers.bulk

However, in any case the following error is appearing:

```
  File "/usr/local/lib/python2.7/json/ __init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/local/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")

```

`TypeError: RequestError(400, u'action_request_validation_exception', {u'status': 400, u'error': {u'root_cause': [{u'reason': u'Validation Failed: 1:index is missing;2: type is missing; u'type': u'action_request_validation_exception'}`

Please evaluate.

Thank you,

---

<div class="post-metadata">

**Author:** ![nkvoll](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@nkvoll](https://discuss.elastic.co/u/nkvoll)\
**Post date:** [April 26, 2016, 11:10am UTC](https://discuss.elastic.co/t/upload-data-via-python-bulk-helper-caused-error/48205/2 "2016-04-26T11:10:24Z")

</div>

I've moved this topic to the Elasticsearch forum, as it seems to be a language client-specific usage question.

---

<div class="post-metadata">

**Author:** ![Jerry\_Sarton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerry_sarton/32/13983_2.png) [@Jerry\_Sarton](https://discuss.elastic.co/u/Jerry_Sarton)\
**Post date:** [December 19, 2016, 4:34pm UTC](https://discuss.elastic.co/t/upload-data-via-python-bulk-helper-caused-error/48205/3 "2016-12-19T16:34:09Z")

</div>

How did you solve this? I have the same issue with Python and elasticsearch 5.1.1

---

<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:** [July 5, 2017, 10:04pm UTC](https://discuss.elastic.co/t/upload-data-via-python-bulk-helper-caused-error/48205/4 "2017-07-05T22:04:47Z")

</div>


