# How to update a document in NEST whose document ID (which is autogenerated) is not known?

**URL:** <https://discuss.elastic.co/t/how-to-update-a-document-in-nest-whose-document-id-which-is-autogenerated-is-not-known/302544>\
**Category:** Elasticsearch\
**Created:** [April 16, 2022, 9:06am UTC](https://discuss.elastic.co/t/how-to-update-a-document-in-nest-whose-document-id-which-is-autogenerated-is-not-known/302544 "2022-04-16T09:06:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanveer\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanveer_khan/32/104438_2.png) [@Tanveer\_Khan](https://discuss.elastic.co/u/Tanveer_Khan)\
**Post date:** [April 16, 2022, 9:06am UTC](https://discuss.elastic.co/t/how-to-update-a-document-in-nest-whose-document-id-which-is-autogenerated-is-not-known/302544/1 "2022-04-16T09:06:54Z")

</div>

[Route("api/CancelSlotAppointment")]  
[HttpGet]  
public string CancelSlotAppointment(string SlotID, bool Cancel)  
{  
var uri = new Uri("[http://localhost:9200](http://localhost:9200)");  
var settings = new ConnectionSettings(uri);  
var client = new ElasticClient(settings);  
var result = client.Update(SlotID, u =\> u  
.Index("slot\_booking")  
.Doc(new  
{  
BookingCanceled = Cancel  
}  
));

```
        return result.ToString();
    }

```

* * *

{

```
            "_index": "slot_booking",

            "_type": "_doc",

            "_id": "0NJZMYABHXYXREFD-lWQ",

            "_score": 1.0,

            "_source": {

                "SlotID": "200",

                "PracticeID": "100",

                "BookingCanceled": false,

                "Confirm": false

            }

        }
```

---

<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:** [May 14, 2022, 9:06am UTC](https://discuss.elastic.co/t/how-to-update-a-document-in-nest-whose-document-id-which-is-autogenerated-is-not-known/302544/2 "2022-05-14T09:06:55Z")

</div>

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