Page updated Nov 14, 2023

Update data

PUT requests

To update an item via the API endpoint:

Future<void> updateTodo() async { try { final restOperation = Amplify.API.put( 'todo/1', body: HttpPayload.json({'name': 'Mow the lawn'}), ); final response = await restOperation.response; print('PUT call succeeded'); print(response.decodeBody()); } on ApiException catch (e) { print('PUT call failed: $e'); } }
1Future<void> updateTodo() async {
2 try {
3 final restOperation = Amplify.API.put(
4 'todo/1',
5 body: HttpPayload.json({'name': 'Mow the lawn'}),
6 );
7 final response = await restOperation.response;
8 print('PUT call succeeded');
9 print(response.decodeBody());
10 } on ApiException catch (e) {
11 print('PUT call failed: $e');
12 }
13}