-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Dio Throws Exception on DELETE Request with 204 Response #2279
Comments
Please let me know if there's any more info I can add. Judging by the error message it seems that Dio is attempting to parse the body of the response, but since the response body is null, it throws this error. The issue does not occur in 5.4.3, so I have downgraded the version for now. Only tested with DELETE requests, I am not sure if other HTTP requests are affected. Tested only in flutter web, I am not sure if other platforms are affected. |
Please add sample code that shows how you call the delete endpoint. Make sure to use the correct generic response type . |
Here's the basic implementation of my HttpProvider class. For brevity, some methods like
Request body:
Response headers:
|
It seems that this might be an issue with the latest transformer from #2239 You set The server sets
so the transformer expects JSON content. This is a violation of the HTTP Spec
But the transformer still probably should be adapted to handle this more gracefully. For now, you can work around this by setting ResponseType to |
Package
dio
Version
5.5.0
Operating-System
Web
Adapter
Default Dio
Output of
flutter doctor -v
Dart Version
3.3.4
Steps to Reproduce
Create a flutter application with dio as a dependency.
Send a DELETE request to an endpoint which returns a 204 "No Content" http status code.
Expected Result
The request goes through without throwing an exception.
Actual Result
The request throws a DioException with the message "SyntaxError: Unexpected end of JSON input".
The text was updated successfully, but these errors were encountered: