[comment]: # translation:outdated

[comment]: # ({0ec30c22-0ec30c22})
# item.update

[comment]: # ({/0ec30c22-0ec30c22})

[comment]: # ({53e9b148-38961105})
### Descrizione

`object item.update(object/array items)`

Questo metodo consente di aggiornare item esistenti.

::: noteclassic
Gli item web non possono essere aggiornati tramite la Zabbix API.
:::

::: noteclassic
Questo metodo è disponibile solo per i tipi di utente *Admin* e *Super admin*. Le autorizzazioni per chiamare il metodo possono essere revocate nelle impostazioni del ruolo utente. Per ulteriori informazioni, vedere [User roles](/manual/web_interface/frontend_sections/users/user_roles).
:::

[comment]: # ({/53e9b148-38961105})

[comment]: # ({7bdceee8-4e151fd6})
### Parametri

`(object/array)` Proprietà dell'item da aggiornare.

La proprietà `itemid` deve essere definita per ogni item, tutte le altre
proprietà sono facoltative. Verranno aggiornate solo le proprietà passate, tutte
le altre rimarranno invariate.

Oltre alle [proprietà standard dell'item](object#item), il metodo
accetta i seguenti parametri.

|Parametro|[Type](/manual/api/reference_commentary#data-types)|Descrizione|
|--|--|------|
|preprocessing|array|Opzioni di [preprocessing dell'item](/manual/api/reference/item/object#item-preprocessing) per sostituire le opzioni di preprocessing correnti.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *sola lettura* per oggetti ereditati o oggetti individuati|
|tags|array|[Tag dell'item](/manual/api/reference/item/object#item-tag).<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *sola lettura* per oggetti individuati|

[comment]: # ({/7bdceee8-4e151fd6})

[comment]: # ({aefff750-aefff750})
### Restituisce i valori

`(object)` Restituisce un oggetto contenente gli ID degli articoli aggiornati
sotto la proprietà `itemids`.

[comment]: # ({/aefff750-aefff750})

[comment]: # ({b41637d2-b41637d2})
### Esempi

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({c681d7b3-5388578b})
#### Abilitazione di un item

Abilitare un item, ovvero impostarne lo stato a "0".

[Richiesta](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.update",
    "params": {
        "itemid": "10092",
        "status": 0
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "10092"
        ]
    },
    "id": 1
}
```

[comment]: # ({/c681d7b3-5388578b})

[comment]: # ({09eff812-0bf89382})
#### Aggiornare un item dipendente

Aggiorna il nome dell'item dipendente e l'ID dell'item principale. Sono consentite solo dipendenze sullo stesso host, pertanto l'item principale e l'item dipendente devono avere lo stesso hostid.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.update",
    "params": {
        "name": "Nome aggiornato dell'item dipendente",
        "master_itemid": "25562",
        "itemid": "189019"
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "189019"
        ]
    },
    "id": 1
}
```

[comment]: # ({/09eff812-0bf89382})

[comment]: # ({509fa40e-8f365363})
#### Aggiornare un item HTTP agent

Abilitare il trapping del valore dell'item.

[Richiesta](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.update",
    "params": {
        "itemid": "23856",
        "allow_traps": 1
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "23856"
        ]
    },
    "id": 1
}
```

[comment]: # ({/509fa40e-8f365363})

[comment]: # ({c593b346-44f323b8})
#### Aggiornamento di un item con preprocessing

Aggiorna un item con la regola di preprocessing dell'item "In range".

[Richiesta](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.update",
    "params": {
        "itemid": "23856",
        "preprocessing": [
            {
                "type": 13,
                "params": "\n100",
                "error_handler": 1,
                "error_handler_params": ""
            }
        ]
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "23856"
        ]
    },
    "id": 1
}
```

[comment]: # ({/c593b346-44f323b8})

[comment]: # ({ebd70da6-dcfb98a0})
#### Aggiornamento di un item script

Aggiornare un item script con uno script diverso e rimuovere i parametri non necessari utilizzati dallo script precedente.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.update",
    "params": {
        "itemid": "23865",
        "parameters": [],
        "params": "Zabbix.log(3, 'Log test');\nreturn 1;"
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "23865"
        ]
    },
    "id": 1
}
```

[comment]: # ({/ebd70da6-dcfb98a0})

[comment]: # ({646fe32a-646fe32a})
### Fonte

CItem::update() in *ui/include/classes/api/services/CItem.php*.

[comment]: # ({/646fe32a-646fe32a})
