Closed bhanuka96 closed 1 year ago
request body is not sent. Look like #1642 has the same issue.
Please make sure your content type has been set properly, and provide reproducible example.
@AlexV525
Content type is set correctly. Nothing is wrong.
It was working normally in dio version 4.0.6
. This issue only happens when upgrade to dio 5.0.0
.
We need reproducible example at least to identify what's going wrong.
@bhanuka96 i think set Headers.formUrlEncodedContentType
in your DIO options is ok , after i set it i can get the request body data
if using Headers.formUrlEncodedContentType
the data
value will convert to string, but in Headers.jsonContentType
will convert data
value as valid json.
maybe can refer what-are-the-differences-between-application-json-and-application-x-www-form-url
@cleong98
Thank you, it works after I changed to Headers.formUrlEncodedContentType
as you suggested
It didn't work when I used Headers.jsonContentType
.
If this is not a bug, I think it should be noted in the doc or changelog since it's working normally before in version 4.0.6
.
@simonpham is welcome, actually i also found the answer in documentation, maybe u are not noticed when you read documentation.
It's addressed already in the CHANGELOG and the migration guide.
It's working after adding contentType: Headers.jsonContentType
. Thanks.
Package
dio
Version
5.0.0
Output of
flutter doctor -v
Dart Version
No response
Steps to Reproduce
any HTTP request not working with 5.0.0.
ex: POST
API
It triggers the null condition
req.body
. I now downgrade to^4.0.6
now, works fine.pubspec.yaml
Expected Result
Working
Actual Result
req.body is null