syedmurtaza108 / chucker-flutter

An HTTP requests inspector inspired by Chucker Android
https://pub.dev/packages/chucker_flutter
MIT License
54 stars 32 forks source link

Unhandled Exception: Read failed when accessing request.bodyFields for request with Content type application/json #6

Closed Dammyololade closed 2 years ago

Dammyololade commented 2 years ago

Describe the bug

Error when sending a post request with a content type application/json. This is because request.bodyFields throws a state error StateError('Cannot access the body fields of a Request without ' 'content-type "application/x-www-form-urlencoded".')

Log

` [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Read failed

0 IOClient.send (package:http/src/io_client.dart:66:7)

#1 FailedRequestClient.send (package:sentry/src/http_client/failed_request_client.dart:109:24) #2 BreadcrumbClient.send (package:sentry/src/http_client/breadcrumb_client.dart:65:24) #3 ChuckerHttpClient.send (package:chucker_flutter/src/http/chucker_http_client.dart:60:22) #4 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:32) ` **Version** Flutter Version: 2.10.3 OS: IOS Chucker Flutter Version : 1.2.0 This can be fixed by changing line 100 on chucker_http_client.dart from `requestBody = request.bodyFields;` to `requestBody = jsonDecode(request.body);`
Dammyololade commented 2 years ago

I've raised a PR https://github.com/syedmurtaza108/chucker-flutter/pull/7 to fix the issue, kindly review and update. I'm happy to provide support for other issues as well. Thanks.

syedmurtaza108 commented 2 years ago

@Dammyololade PR merged and available with the latest release published on pub.dev. As a sign of appreciation, I have added you as a contributor in ReadMe.md file ReaMe file.