retrofit.dart icon indicating copy to clipboard operation
retrofit.dart copied to clipboard

fix: Add Missing Mapping of DateTime in Multipart

Open Sadhorsephile opened this issue 8 months ago • 0 comments

Problem

If we have a request like this:

  @MultiPart()
  @POST('/api/some/path/')
  Future<SomeResponse> requestName({
    @Part(name: 'full_name') required String fullName,
    @Part(name: 'birth_date') required DateTime birthDate,

we'll get a toJson() method have to add to DateTime Exception.

Solution

If part param doesn't have the toJson() method, we have to check whether this is DateTime. If so, we use atoIso8601String method.

Sadhorsephile avatar Jun 05 '24 13:06 Sadhorsephile