# Can't update through API

**URL:** <https://discourse.getcockpit.com/t/cant-update-through-api/580>\
**Category:** General\
**Created:** [February 16, 2019, 5:19pm UTC](https://discourse.getcockpit.com/t/cant-update-through-api/580 "2019-02-16T17:19:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hypothesis-github](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@Hypothesis-github](https://discourse.getcockpit.com/u/Hypothesis-github)\
**Post date:** [February 16, 2019, 5:19pm UTC](https://discourse.getcockpit.com/t/cant-update-through-api/580/1 "2019-02-16T17:19:30Z")

</div>

I am not familiar with Ajax and this may seem like a silly question but

according to the documents

Create / Update collection entries

```auto
fetch('/api/collections/save/posts?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        data: {...}
    })
})
.then(res=>res.json())
.then(entry => console.log(entry));

```

I can insert new entries but I cannot update any of my entries.  
would you please give me an example to how I can update an existing entry ?

---

<div class="post-metadata">

**Author:** ![pauloamgomes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pauloamgomes/32/48_2.png) [@pauloamgomes](https://discourse.getcockpit.com/u/pauloamgomes)\
**Post date:** [February 17, 2019, 6:42pm UTC](https://discourse.getcockpit.com/t/cant-update-through-api/580/2 "2019-02-17T18:42:03Z")

</div>

@Hypothesis-github  
An update is triggered when your data structure contains a valid `_id`, are you passing the entry `_id` in the request? For me below works well:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/5669458bae8c3e144ace93bf7b3c36ccc939bc44.png)

---

<div class="post-metadata">

**Author:** ![Hypothesis-github](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@Hypothesis-github](https://discourse.getcockpit.com/u/Hypothesis-github)\
**Post date:** [February 17, 2019, 7:02pm UTC](https://discourse.getcockpit.com/t/cant-update-through-api/580/3 "2019-02-17T19:02:37Z")

</div>

Thanks dude, I got it working with you mentioning the “\_id”

---

<div class="post-metadata">

**Author:** ![appsdevpk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/appsdevpk/32/464_2.png) [@appsdevpk](https://discourse.getcockpit.com/u/appsdevpk)\
**Post date:** [February 2, 2020, 8:57pm UTC](https://discourse.getcockpit.com/t/cant-update-through-api/580/4 "2020-02-02T20:57:16Z")

</div>

This solution is not working with me, take a look at my code and the payload being sent

 ![cannot_update_entry_api](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/480f26d13ffd3dfad52e4629bf9ed685361379dc.png)
