Closed edily-learn closed 1 year ago
I am facing the same issue on a real device with latest Amplify packages.
Thanks for raising the ticket @edily-learn
Hi @edily-learn @deep-aeo can you share the code you're using to run the delete command? What you are placing in the body?
@fjnoyp please find below examples.
**Example #1**
Future<String> removeLikeVideo(Videos video, String reactorID) async {
try {
String body = json.encode({
"video_id": video.id,
"reaction_type": "heart",
"reacting_user_id": reactorID,
"creators_user_id": video.creatorID,
"timestamp": video.timestamp,
"reaction_body": ""
});
RestOptions options = RestOptions(
path: '/videos/reactions', body: Uint8List.fromList(body.codeUnits));
RestOperation restOperation = Amplify.API.delete(restOptions: options);
RestResponse response = await restOperation.response;
return String.fromCharCodes(response.data);
} on ApiException catch (e) {
return "request failed";
}
}
**Example #2**
Future<void> removeFollowUser(String followingUserId, String followedUserId) async {
try {
String body = json.encode({
"followingUser": followingUserId,
"followedUser": followedUserId,
});
RestOptions options = RestOptions(
path: '/following', body: Uint8List.fromList(body.codeUnits));
RestOperation restOperation = Amplify.API.delete(restOptions: options);
await restOperation.response;
} on ApiException catch (e) {
return;
}
}
they values are all strings
Hi @edily-learn @deep-aeo thanks again for reaching out. The underlying Amplify-Android library which Amplify-Flutter is built on top of does not allow data in Delete operations. Our code passes the data object to their side, so if Amplify-Android updates their code and Amplify-Flutter updates to their new version, this issue will be fixed.
Let's create this issue on their repo and see what they have to say.
Android issue created: https://github.com/aws-amplify/amplify-android/issues/1729
thank you @fjnoyp
Hi, I saw that amplify-flutter 0.6.2 contains amplify-android 1.36.1 that supposedly already encompasses the fix for https://github.com/aws-amplify/amplify-android/issues/1729. Has anyone been able to verify the fix? From my tests, the DELETE API now accepts request body, but the content of the body itself does not seem to be included upon sending the request.
Hello - We have recently released a new developer preview version of the API category (amplify_flutter v1.0.0-next.1). This new version is a full re-write of the API category in dart, and it supports Mobile, Desktop, and Web. This issue is addressed in this new version. You can see a code example for a PUT request with a body and just change the method to .delete
in your code (the DELETE example on the docs does not include a body but it can be included). I will update this issue again once this new version is out of developer preview.
Let me know if you have any questions!
https://docs.amplify.aws/lib/restapi/update/q/platform/flutter/
This issue has been addressed in v1.0.0 of Amplify Flutter, which is now stable. This release also includes web and desktop support for Auth, API, Analytics, and Storage. You can see the list of new features and bug fixes in the release notes, and see more details on how to migrate in the upgrade guide.
Description
Unable to send body to DELETE request in API Gateway
I/flutter ( 7761): Like xxxx call failed: ApiException(message: HTTP method does not support data object! DELETE, recoverySuggestion: Try sending the request without any data in the options., underlyingException: null)
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Android Device/Emulator API Level
API 32+
Environment
Dependencies
Device
Pixel 5
OS
Android 12
CLI Version
8.1.0
Additional Context