# Python update using script\_id

**URL:** <https://discuss.elastic.co/t/python-update-using-script-id/52775>\
**Category:** Elasticsearch\
**Created:** [June 14, 2016, 6:52pm UTC](https://discuss.elastic.co/t/python-update-using-script-id/52775 "2016-06-14T18:52:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tammo\_Heeren](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Tammo\_Heeren](https://discuss.elastic.co/u/Tammo_Heeren)\
**Post date:** [June 14, 2016, 6:52pm UTC](https://discuss.elastic.co/t/python-update-using-script-id/52775/1 "2016-06-14T18:52:27Z")

</div>

Essentially I am trying to update an existing document using python and the update api. When I do the following in Sense it work fine. The script in stored and scripting is enabled.

```
POST /test/logevent/AVVQF8QuKsObI6Cw3KiB
{
  "test": "test"
}

POST /test/logevent/AVVQF8QuKsObI6Cw3KiB/_update?lang=groovy&script_id=event_setpoint_vacuum

GET /test/logevent/AVVQF8QuKsObI6Cw3KiB

```

As the output I get

```
{
  "_index": "test",
  "_type": "logevent",
  "_id": "AVVQF8QuKsObI6Cw3KiB",
  "_version": 2,
  "found": true,
  "_source": {
    "test": "test",
    "extraction": {},
    "last_updated": "2016-06-14T18:07:02.318Z"
  }
}

```

Which is what I expect. However, if I call the update via the python API with the following code

```
def update(self, id, script_id):
    return self.es.update(
        index=configuration.TEST_INDEX,
        doc_type='logevent',
        id=id,
        script_id=script_id,
        lang='groovy',
        params={},
    )

```

I see in the logging info

```
2016-06-14 11:48:17,110 | elasticsearch | WARNING | POST /test/logevent/AVVQF8QuKsObI6Cw3KiB/_update?lang=groovy&script_id=event_setpoint_vacuum [status:400 request:0.081s]

```

This is the more detailed error message:

```
Error
Traceback (most recent call last):
  File "/home/theeren/PyCharmProjects/logalizerES/events/test_setpoint_vacuum.py", line 54, in test_search_setpoint_decrement_extrusion_max
    self.update(id, Event.id)
  File "/home/theeren/PyCharmProjects/logalizerES/elasticcore.py", line 128, in update
    params={},
  File "/home/theeren/logalizervenv/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/theeren/logalizervenv/local/lib/python2.7/site-packages/elasticsearch/client/ __init__.py", line 460, in update
    doc_type, id, '_update'), params=params, body=body)
  File "/home/theeren/logalizervenv/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 329, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/home/theeren/logalizervenv/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 109, in perform_request
    self._raise_error(response.status, raw_data)
  File "/home/theeren/logalizervenv/local/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 108, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
RequestError: TransportError(400, u'illegal_argument_exception', u'[Ultra-Marine][10.0.20.213:9300][indices:data/write/update[s]]')

```

I can not figure out what is wrong here.

---

<div class="post-metadata">

**Author:** ![honzakral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honzakral/32/44958_2.png) [@honzakral](https://discuss.elastic.co/u/honzakral)\
**Post date:** [June 16, 2016, 9:37am UTC](https://discuss.elastic.co/t/python-update-using-script-id/52775/2 "2016-06-16T09:37:37Z")

</div>

Hi, at first glance everything seems correct, could you please enable `DEBUG` logging for elasticsearch logger to also see the body being sent?

```auto
import logging
logger = logging.getLogger('elasticsearch')
logger.setLevel(logging.DEBUG)

```

Thanks!

---

<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:43pm UTC](https://discuss.elastic.co/t/python-update-using-script-id/52775/3 "2017-07-05T22:43:20Z")

</div>


