Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot perform DELETE action with body from android device #1569

Closed
2 of 9 tasks
edily-learn opened this issue May 3, 2022 · 10 comments
Closed
2 of 9 tasks

Cannot perform DELETE action with body from android device #1569

edily-learn opened this issue May 3, 2022 · 10 comments
Labels
Android Issues specific to the Android Platform bug Something is not working; the issue has reproducible steps and has been reproduced fixed-in-release-candidate Issues that have been addressed in the current release-candidate branch requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed. REST API Issues related to the API (REST) Category

Comments

@edily-learn
Copy link

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

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Storage

Steps to Reproduce

  1. With any android device an attempt to use a Delete action with a body will throw an exception.

Screenshots

No response

Platforms

  • iOS
  • Android

Android Device/Emulator API Level

API 32+

Environment

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.5, on macOS 12.2.1 21D62 darwin-arm, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.66.2)
[✓] VS Code (version 1.62.3)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

Dependencies

Dart SDK 2.16.2
Flutter SDK 2.10.5

dependencies:
- adaptive_action_sheet 2.0.1 [flutter universal_io]
- amplify_api 0.2.9 [amplify_api_plugin_interface amplify_core flutter plugin_platform_interface]
- amplify_auth_cognito 0.2.9 [flutter amplify_auth_plugin_interface amplify_core collection plugin_platform_interface]
- amplify_datastore 0.2.9 [flutter amplify_datastore_plugin_interface amplify_core plugin_platform_interface meta collection async]
- amplify_flutter 0.2.9 [flutter plugin_platform_interface amplify_storage_plugin_interface amplify_analytics_plugin_interface amplify_auth_plugin_interface amplify_datastore_plugin_interface amplify_api_plugin_interface amplify_core]
- amplify_storage_s3 0.2.9 [flutter amplify_storage_plugin_interface plugin_platform_interface amplify_core]
- auto_size_text 3.0.0 [flutter]
- cached_network_image 3.1.0+1 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- catcher 0.6.9 [flutter flutter_web_plugins fluttertoast device_info_plus device_info_plus_platform_interface package_info_plus mailer dio flutter_mailer logging sentry universal_io]
- chewie 1.2.2 [cupertino_icons flutter provider video_player wakelock]
- cupertino_icons 1.0.4
- expandable 5.0.1 [flutter]
- expandable_text 2.2.0 [flutter]
- file_picker 4.5.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32]
- firebase_core 1.10.5 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_dynamic_links 4.0.2 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface]
- firebase_remote_config 1.0.4 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta typed_data vector_math sky_engine]
- flutter_login 3.0.0 [flutter font_awesome_flutter provider another_transformer_page_view another_flushbar flutter_signin_button quiver url_launcher]
- flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml]
- font_awesome_flutter 9.2.0 [flutter]
- get 4.6.1 [flutter]
- get_storage 2.0.3 [flutter get path_provider]
- google_fonts 2.1.0 [flutter http path_provider crypto]
- hexcolor 2.0.5 [flutter flutter_web_plugins]
- http 0.13.4 [async http_parser meta path]
- image_picker 0.8.4+4 [flutter flutter_plugin_android_lifecycle image_picker_for_web image_picker_platform_interface]
- intl 0.17.0 [clock path]
- lottie 1.3.0 [archive flutter path vector_math]
- material_floating_search_bar 0.3.7 [flutter meta]
- package_info_plus 1.4.2 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web]
- permission_handler 9.2.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface]
- pin_code_fields 7.3.0 [flutter]
- scroll_to_index 2.1.0 [flutter]
- share_plus 3.0.4 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web]
- substring_highlight 1.0.33 [flutter]
- timeago 3.2.2
- url_launcher 6.0.13 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- uuid 3.0.5 [crypto]
- video_compress 3.1.1 [flutter]
- video_player 2.2.7 [flutter meta video_player_platform_interface video_player_web html]
- video_trimmer 1.0.0 [flutter video_player ffmpeg_kit_flutter video_thumbnail path_provider intl path]

dependency overrides:
- platform 3.1.0
- provider 6.0.1 [collection flutter nested]

transitive dependencies:
- amplify_analytics_plugin_interface 0.2.9 [amplify_core flutter meta]
- amplify_api_plugin_interface 0.2.9 [amplify_core collection flutter meta uuid]
- amplify_auth_plugin_interface 0.2.9 [flutter meta amplify_core]
- amplify_core 0.2.9 [plugin_platform_interface meta flutter uuid]
- amplify_datastore_plugin_interface 0.2.9 [flutter meta collection date_time_format uuid amplify_core]
- amplify_storage_plugin_interface 0.2.9 [flutter meta amplify_core]
- another_flushbar 1.10.24 [pedantic flutter]
- another_transformer_page_view 1.0.1 [pedantic flutter]
- archive 3.3.0 [crypto path]
- async 2.8.2 [collection meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.0.1 [flutter flutter_cache_manager cached_network_image_platform_interface]
- characters 1.2.0
- charcode 1.3.1
- clock 1.1.0
- collection 1.15.0
- cross_file 0.3.1+4 [flutter meta]
- crypto 3.0.1 [collection typed_data]
- csslib 0.17.1 [source_span]
- date_time_format 2.0.1
- device_info_plus 3.2.3 [flutter device_info_plus_platform_interface device_info_plus_macos device_info_plus_linux device_info_plus_web device_info_plus_windows]
- device_info_plus_linux 2.1.1 [device_info_plus_platform_interface file flutter meta]
- device_info_plus_macos 2.2.3 [device_info_plus_platform_interface flutter]
- device_info_plus_platform_interface 2.3.0+1 [flutter meta plugin_platform_interface]
- device_info_plus_web 2.1.0 [device_info_plus_platform_interface flutter_web_plugins flutter]
- device_info_plus_windows 2.1.1 [device_info_plus_platform_interface ffi flutter win32]
- dio 4.0.6 [http_parser path]
- fake_async 1.2.0 [clock collection]
- ffi 1.1.2
- ffmpeg_kit_flutter 4.5.0-LTS [ffmpeg_kit_flutter_platform_interface flutter]
- ffmpeg_kit_flutter_platform_interface 0.1.0 [flutter plugin_platform_interface]
- file 6.1.2 [meta path]
- firebase_core_platform_interface 4.2.5 [collection flutter meta plugin_platform_interface]
- firebase_core_web 1.6.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_dynamic_links_platform_interface 0.2.0+2 [firebase_core flutter meta plugin_platform_interface]
- firebase_remote_config_platform_interface 1.1.4 [firebase_core flutter meta plugin_platform_interface]
- firebase_remote_config_web 1.0.10 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js]
- flutter_blurhash 0.6.0 [flutter meta pedantic]
- flutter_cache_manager 3.1.3 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid]
- flutter_mailer 2.0.1 [flutter]
- flutter_plugin_android_lifecycle 2.0.2 [flutter]
- flutter_signin_button 2.0.0 [flutter font_awesome_flutter]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph typed_data]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta typed_data vector_math]
- fluttertoast 8.0.9 [flutter flutter_web_plugins]
- html 0.15.0 [csslib source_span]
- http_parser 4.0.0 [charcode collection source_span string_scanner typed_data]
- image_picker_for_web 2.1.3 [flutter flutter_web_plugins image_picker_platform_interface meta]
- image_picker_platform_interface 2.3.0 [flutter http meta plugin_platform_interface cross_file]
- js 0.6.3
- logging 1.0.2
- mailer 5.1.0 [async logging intl mime path pedantic meta]
- matcher 0.12.11 [stack_trace]
- material_color_utilities 0.1.3
- meta 1.7.0
- mime 1.0.1
- nested 1.0.0 [flutter]
- octo_image 1.0.0+1 [flutter flutter_blurhash]
- package_info_plus_linux 1.0.5 [package_info_plus_platform_interface flutter path]
- package_info_plus_macos 1.3.0 [flutter]
- package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface]
- package_info_plus_web 1.0.5 [flutter flutter_web_plugins http meta package_info_plus_platform_interface]
- package_info_plus_windows 1.0.5 [package_info_plus_platform_interface ffi flutter win32]
- path 1.8.0
- path_drawing 0.5.1 [vector_math meta path_parsing flutter]
- path_parsing 0.2.1 [vector_math meta]
- path_provider 2.0.9 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows]
- path_provider_android 2.0.13 [flutter path_provider_platform_interface]
- path_provider_ios 2.0.8 [flutter path_provider_platform_interface]
- path_provider_linux 2.0.2 [flutter path path_provider_platform_interface xdg_directories]
- path_provider_macos 2.0.2 [flutter]
- path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface]
- path_provider_windows 2.0.3 [ffi flutter meta path path_provider_platform_interface win32]
- pedantic 1.11.1
- permission_handler_android 9.0.2+1 [flutter permission_handler_platform_interface]
- permission_handler_apple 9.0.4 [flutter permission_handler_platform_interface]
- permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface]
- permission_handler_windows 0.1.0 [flutter permission_handler_platform_interface]
- petitparser 4.1.0 [meta]
- plugin_platform_interface 2.0.2 [meta]
- process 4.2.3 [file path platform]
- quiver 3.0.1 [matcher]
- rxdart 0.27.2
- sentry 6.5.1 [http meta stack_trace uuid]
- share_plus_linux 2.0.4 [share_plus_platform_interface file flutter meta url_launcher]
- share_plus_macos 2.0.2 [share_plus_platform_interface flutter]
- share_plus_platform_interface 2.0.1 [flutter meta mime plugin_platform_interface]
- share_plus_web 2.0.4 [share_plus_platform_interface url_launcher flutter flutter_web_plugins meta]
- share_plus_windows 2.0.3 [share_plus_platform_interface flutter meta url_launcher]
- sky_engine 0.0.99
- source_span 1.8.1 [collection path term_glyph]
- sqflite 2.0.0+4 [flutter sqflite_common path]
- sqflite_common 2.0.1 [synchronized path meta]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- string_scanner 1.1.0 [charcode source_span]
- synchronized 3.0.0
- term_glyph 1.2.0
- test_api 0.4.8 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0 [collection]
- universal_io 2.0.4 [collection crypto meta typed_data]
- url_launcher_linux 2.0.1 [flutter]
- url_launcher_macos 2.0.1 [flutter]
- url_launcher_platform_interface 2.0.4 [flutter plugin_platform_interface]
- url_launcher_web 2.0.4 [flutter flutter_web_plugins meta url_launcher_platform_interface]
- url_launcher_windows 2.0.2 [flutter]
- vector_math 2.1.1
- video_player_platform_interface 4.2.0 [flutter flutter_test meta]
- video_player_web 2.0.3 [flutter flutter_web_plugins meta video_player_platform_interface]
- video_thumbnail 0.4.6 [flutter]
- wakelock 0.5.3+3 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows]
- wakelock_macos 0.1.0+2 [flutter flutter_web_plugins wakelock_platform_interface]
- wakelock_platform_interface 0.2.1+2 [flutter meta]
- wakelock_web 0.2.0+2 [flutter flutter_web_plugins js wakelock_platform_interface]
- wakelock_windows 0.1.0+1 [flutter wakelock_platform_interface win32]
- win32 2.5.2 [ffi]
- xdg_directories 0.2.0 [meta path process]
- xml 5.1.2 [collection meta petitparser]

Device

Pixel 5

OS

Android 12

CLI Version

8.1.0

Additional Context

image

@Jordan-Nelson Jordan-Nelson added REST API Issues related to the API (REST) Category pending-triage This issue is in the backlog of issues to triage labels May 3, 2022
@deep-aeo
Copy link

deep-aeo commented May 4, 2022

I am facing the same issue on a real device with latest Amplify packages.

Thanks for raising the ticket @edily-learn

@fjnoyp
Copy link
Contributor

fjnoyp commented May 4, 2022

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?

@edily-learn
Copy link
Author

edily-learn commented May 4, 2022

@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;
    }
  }

@edily-learn
Copy link
Author

they values are all strings

@fjnoyp
Copy link
Contributor

fjnoyp commented May 6, 2022

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.

@fjnoyp fjnoyp added Android Issues specific to the Android Platform requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed. labels May 6, 2022
@fjnoyp
Copy link
Contributor

fjnoyp commented May 6, 2022

Android issue created: aws-amplify/amplify-android#1729

@edily-learn
Copy link
Author

thank you @fjnoyp

@Jordan-Nelson Jordan-Nelson added bug Something is not working; the issue has reproducible steps and has been reproduced and removed pending-triage This issue is in the backlog of issues to triage labels Jun 9, 2022
@AALLx
Copy link

AALLx commented Jul 17, 2022

Hi, I saw that amplify-flutter 0.6.2 contains amplify-android 1.36.1 that supposedly already encompasses the fix for aws-amplify/amplify-android#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.

@ragingsquirrel3
Copy link
Contributor

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/

@ragingsquirrel3 ragingsquirrel3 added the pending-release Issues that have been addressed in main but have not been released label Nov 18, 2022
@Jordan-Nelson Jordan-Nelson added fixed-in-release-candidate Issues that have been addressed in the current release-candidate branch and removed pending-release Issues that have been addressed in main but have not been released labels Mar 2, 2023
@Jordan-Nelson
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues specific to the Android Platform bug Something is not working; the issue has reproducible steps and has been reproduced fixed-in-release-candidate Issues that have been addressed in the current release-candidate branch requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed. REST API Issues related to the API (REST) Category
Projects
None yet
Development

No branches or pull requests

6 participants