Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

LegacyYou are viewing Gen 1 documentation. Switch to the latest Gen 2 docs →

Update data

PUT requests

To update an item via the API endpoint:

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)
);
val request = RestOptions.builder()
.addPath("/todo/1")
.addBody("{\"name\":\"Mow the lawn\"}".toByteArray())
.build()
Amplify.API.put(request,
{ Log.i("MyAmplifyApp", "PUT succeeded: $it") },
{ Log.e("MyAmplifyApp", "PUT failed", it) }
)
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)
}
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)
);