Closed paulopicasso closed 10 months ago
By default retrofit has content type application/json
But dio from version 5 remove this by default.
Try to add to your dio client:
final dioClient = Dio(
BaseOptions(
contentType: Headers.jsonContentType, // <- this line
),
);
Yes that seems to work. Thanks!
Hi @Carapacik, I'm having a related issue. I have some PATCH endpoints which consume the content type application/json-patch+json
. All other endpoints accept the standard application/json
, so I cannot globally set the content type for Dio. I was wondering, should maybe the code generation also check if a specific content-type is required by the swagger and annotate the retrofit method with @Header
? Something like this:
@Header('Content-Type: application/json-patch+json')
@PATCH('/users')
Future<User> patchUser({
@Body() required JsonPatch patch,
});
I was wondering, should maybe the code generation also check if a specific content-type is required by the swagger and annotate the retrofit method with
@Header
?
Maybe something like this
@Headers(<String, String>{'Content-Type': 'application/json-patch+json'})
@PATCH('/users')
Future<User> patchUser({
@Body() required JsonPatch patch,
});
I think it's worth considering an implementation when application/json is missing.
Hello! I noticed that despite the following part in the swagger json:
a content-type header with
application/json
value is not added to the endpoint which causes issues in my app.Could this be added?