> For the complete documentation index, see [llms.txt](https://klearstack.gitbook.io/klearstack-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://klearstack.gitbook.io/klearstack-api-documentation/datasources/update-record-of-a-datasource.md).

# Update Record of a Datasource

Endpoint Name: `update_datasource_row`

Request type : `POST`

Authorization: Bearer token as header

Endpoint Details: The `update_datasource_row` endpoint will be used to update a record in datasource.

<table data-header-hidden><thead><tr><th width="123"></th><th></th></tr></thead><tbody><tr><td>Method</td><td>URL</td></tr><tr><td>POST</td><td><code>URL/access/klearstack/update_datasource_row</code></td></tr></tbody></table>

### Request Body

<table data-header-hidden><thead><tr><th width="190"></th><th width="101"></th><th width="112.2728271484375"></th><th></th></tr></thead><tbody><tr><td>Params</td><td>Values</td><td>Required</td><td>Description</td></tr><tr><td>company_name</td><td>string</td><td>Yes</td><td>Name of the company for which the user is logging in</td></tr><tr><td>datasource_name </td><td>string </td><td>Yes</td><td>Name of the datasource</td></tr><tr><td>id</td><td>string</td><td>Yes</td><td>ID of record to be updated</td></tr><tr><td>data</td><td>string (JSON)</td><td>Yes</td><td><p>A valid JSON string that contains info that needs to be updated</p><p>Example : {"USER_FIRST_NAE": "Marti",</p><p>"USER_LAST_NAME": "URIB"}</p></td></tr></tbody></table>

### Shell (cURL)

* Request Body

```sh
curl --location "URL/access/klearstack/update_datasource_row" \
  --header "Authorization: Bearer your_token_here" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "datasource_name=Replace_Datasource_Name_Here" \
  --form "id=Replace_Record_ID_Here" \
  --form 'data={
    "USER_FIRST_NAME": "Marti",
    "USER_LAST_NAME": "URIB"
  }'
```

### Python

* Request Body

```python
import requests

url = "URL/access/klearstack/update_datasource_row"

payload = {'company_name': 'Replace_Company_Name_Here',
'datasource_name': 'Replace_Datasource_Name_Here',
'id': 'Replace_Record_ID_Here',
'data': '{
    "USER_FIRST_NAME": "Marti",
    "USER_LAST_NAME": "URIB"
  }'}
files=[

]
headers = {
  'Authorization': 'Bearer your_token_here'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

### Java (OkHttp)

* Request Body

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("company_name", "Replace_Your_Company_Name_Here")
  .addFormDataPart("datasource_name", "Replace_Your_Datasource_Name_Here")
  .addFormDataPart("id", "Replace_Your_Record_ID_Here")
  .addFormDataPart("data", "{\n" +
    "    \"USER_FIRST_NAME\": \"Replace_FirstName\",\n" +
    "    \"USER_LAST_NAME\": \"Replace_LastName\"\n" +
    "  }")
  .build();
Request request = new Request.Builder()
  .url("URL/access/klearstack/update_datasource_row")
  .method("POST", body)
  .addHeader("Authorization", "Bearer Replace_Your_Token_Here")
  .build();
Response response = client.newCall(request).execute();
```

### Node.js (Axios)

* Request Body

```javascript
const axios = require('axios');
const FormData = require('form-data');

let formData = new FormData();
formData.append('company_name', 'Replace_Your_Company_Name_Here');
formData.append('datasource_name', 'Replace_Your_Datasource_Name_Here');
formData.append('id', 'Replace_Your_Record_ID_Here');
formData.append('data', '{\r\n    "USER_FIRST_NAME": "Replace_FirstName",\r\n    "USER_LAST_NAME": "Replace_LastName"\r\n  }');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'URL/access/klearstack/update_datasource_row',
  headers: { 
    'Authorization': 'Bearer Replace_Your_Token_Here', 
    ...formData.getHeaders()
  },
  data: formData
};

axios.request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });

```

### JavaScript (XHR)

* Request Body

```javascript
// WARNING: For POST requests, body is set to null by browsers.

var formData = new FormData();
formData.append("company_name", "Replace_Your_Company_Name_Here");
formData.append("datasource_name", "Replace_Your_Datasource_Name_Here");
formData.append("id", "Replace_Your_Record_ID_Here");
formData.append("data", "{\r\n    \"USER_FIRST_NAME\": \"Replace_FirstName\",\r\n    \"USER_LAST_NAME\": \"Replace_LastName\"\r\n  }");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "URL/access/klearstack/update_datasource_row");
xhr.setRequestHeader("Authorization", "Bearer Replace_Your_Token_Here");

xhr.send(formData);
```

### API Response&#x20;

<table data-header-hidden><thead><tr><th width="145"></th><th></th></tr></thead><tbody><tr><td>Status code</td><td>Example Response</td></tr><tr><td>200</td><td><p><code>{</code></p><p>    <code>"success": "Document updated successfully.",</code></p><p>     <code>“release_version”:”7.8.9”</code></p><p><code>}</code></p></td></tr><tr><td>400</td><td><p><code>{</code></p><p>    <code>"error": "Invalid key: USER_FIRST_NAE"</code></p><p><code>}</code></p></td></tr></tbody></table>
