## PUT requests

To update an item via the API endpoint:

<BlockSwitcher>
<Block name="Java">

```java
RestOptions options = RestOptions.builder()
    .addPath("/todo/1")
    .addBody("{\"name\":\"Mow the lawn\"}".getBytes())
    .build();

Amplify.API.put(options,
    response -> Log.i("MyAmplifyApp", "PUT succeeded: " + response),
    error -> Log.e("MyAmplifyApp", "PUT failed.", error)
);
```

</Block>
<Block name="Kotlin - Callbacks">

```kotlin
val request = RestOptions.builder()
    .addPath("/todo/1")
    .addBody("{\"name\":\"Mow the lawn\"}".getBytes())
    .build()

Amplify.API.put(request,
    { Log.i("MyAmplifyApp", "PUT succeeded: $it") },
    { Log.e("MyAmplifyApp", "PUT failed", it) }
)
```

</Block>
<Block name="Kotlin - Coroutines">

```kotlin
val request = RestOptions.builder()
    .addPath("/todo/1")
    .addBody(JSONObject()
        .put("name", "Mow the lawn")
        .toString()
        .toByteArray())
    .build()
try {
    val response = Amplify.API.put(request)
    Log.i("MyAmplifyApp", "PUT succeeded: $response")
} catch (error: ApiException) {
    Log.e("MyAmplifyApp", "PUT failed", it)
}
```

</Block>
<Block name="RxJava">

```java
RestOptions options = RestOptions.builder()
    .addPath("/todo/1")
    .addBody("{\"name\":\"Mow the lawn\"}".getBytes())
    .build();

RxAmplify.API.put(options)
    .subscribe(
          response -> Log.i("MyAmplifyApp", "PUT succeeded: " + response),
          error -> Log.e("MyAmplifyApp", "PUT failed.", error)
    );
```

</Block>
</BlockSwitcher>
