Mohammad Alotol
Mohammad Alotol

Reputation: 1477

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

Upvotes: 1

Views: 2706

Answers (1)

Miftakhul Arzak
Miftakhul Arzak

Reputation: 1857

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);

Upvotes: 3

Related Questions