Search code examples
flutterretrofit

How to send a request with file upload in flutter retrofit


I'm using flutter retrofit package and I need to implement a request as shown in attached postman screenshot

enter image description here

this is what I do, but it didn't work

  @override
  @POST('/update/document')
  @MultiPart()
  Stream<double> uploadDocument(@Part() int id, @Part() File document);

the problem was that the file "document" not added to parameters list


Solution

  • Add name parameter inside your @Part annotation.

      @override
      @POST('/update/document')
      @MultiPart()
      Stream<double> uploadDocument(@Part(name:"id") int id,
                                    @Part(name:"document") File document);