# Updating a document with elasticsearchjs using typescript throws error

**URL:** <https://discuss.elastic.co/t/updating-a-document-with-elasticsearchjs-using-typescript-throws-error/197798>\
**Category:** Elasticsearch\
**Created:** [September 3, 2019, 8:59am UTC](https://discuss.elastic.co/t/updating-a-document-with-elasticsearchjs-using-typescript-throws-error/197798 "2019-09-03T08:59:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish\_kakoti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manish_kakoti/32/53285_2.png) [@manish\_kakoti](https://discuss.elastic.co/u/manish_kakoti)\
**Post date:** [September 3, 2019, 8:59am UTC](https://discuss.elastic.co/t/updating-a-document-with-elasticsearchjs-using-typescript-throws-error/197798/1 "2019-09-03T08:59:51Z")

</div>

I tried updating a document using elasticsearchjs, using:

```auto
export async function esUpdate (index, id, body) {
 
  return es.update({
    body: JSON.stringify(body),
    id,
    index,
    refresh: true,
    type: DocType
  }).catch(logAndRethrow)
}

It throws error : `Elasticsearch error: {\"msg\":\"[action_request_validation_exception] Validation Failed: 1: script or doc is missing;`
```

---

<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 1, 2019, 9:00am UTC](https://discuss.elastic.co/t/updating-a-document-with-elasticsearchjs-using-typescript-throws-error/197798/2 "2019-10-01T09:00:24Z")

</div>

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