# Modificar elemento

Para modificar un elemento en una Master Db en Persat, se debe enviar un PUT como el que se especifica a continuación.

<mark style="color:orange;">`PUT`</mark> `https://api.persat.com.ar/v1/masterdbvalues/mdb_id/field_1`

#### Path Parameters

| Name                                       | Type   | Description                            |
| ------------------------------------------ | ------ | -------------------------------------- |
| mdb\_id<mark style="color:red;">\*</mark>  | Number | Identificador de la Master db          |
| field\_1<mark style="color:red;">\*</mark> | String | Identificador del elemento a modificar |

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer API\_KEY  |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json |

#### Request Body

| Name                                     | Type   | Description                                         |
| ---------------------------------------- | ------ | --------------------------------------------------- |
| fields<mark style="color:red;">\*</mark> | Object | JSON Object con los campos del elemento a insertar. |

{% tabs %}
{% tab title="200: OK La consulta se ejecutó con éxito" %}

{% endtab %}

{% tab title="404: Not Found La master db especificada no existe" %}

```json
{
    "success": false,
    "error": {
        "status": 404,
        "type": "NOT_FOUND",
        "userMessage": "No existe el mdb_id: 2313213"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Error en alguno de los campos enviados. userMessage contiene informacipon adicional." %}

```javascript
{
    "success": false,
    "error": {
        "status": 400,
        "type": "BAD_REQUEST",
        "userMessage": "'mdb_id' es un number (entero) obligatorio"
    }
}
```

{% endtab %}

{% tab title="409: Conflict Conflicto. Quiero modificar el field\_1 y ya existe otro elemento con este mismo field\_1" %}

```json
{
    "success": false,
    "error": {
        "status": 409,
        "type": "CONFLICT",
        "userMessage": "No se pudo modificar el field_1 del mb value, ya que existe otro con ese mismo identificador: 'pinza'"
    }
}json
```

{% endtab %}
{% endtabs %}

### Ejemplo de request

En este ejemplo vamos a modificar un campo de un elemento particular. Pero no vamos a modificar su identificador (fields.1), aunque podríamos hacerlo si enviamos ese dato en el body.

* mdb\_id: <mark style="color:blue;">4</mark>
* field\_1 (Identificador del elemento): <mark style="color:green;">DEST-123AALK</mark>

Asi sería la consulta

PUT - \*\*<https://api.persat.com.ar/v1**/masterdbvalues/><mark style="color:blue;">4</mark>/<mark style="color:green;">DEST-123AALK</mark>

### body

```json
{
    "fields": {
        "5": "Naranja"
    }
}
```

{% hint style="info" %}
Los valores a insertar son siempre strings, mas alla de que en la definición de la Master db sean de tipo Número, email, link, etc.&#x20;

Por el momento, no se realizan validaciones durante la inserción o modificación de los campos
{% endhint %}

### Analizando la Respuesta

En caso que no haya ningun error, obtenemos

```json
{
    "success": true,
    "data": {
        "mdb_id": 4,
        "fields": {
            "1": "DEST-123AALK",
            "2": "Destornillador perillero",
            "5": "Naranja"
            "6": ""
        },
        "updated": "2022-05-20T14:23:24.000Z"
    }
}
```

La respuesta contiene al elemento modificado y tiene la misma estructura que lo que se recibe en la sección [Obtener elemento](/entidades-basicas/master-db/obtener-elemento.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.persat.com.ar/entidades-basicas/master-db/modificar-elemento.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
