0

I need to upload signature image inside Service Agreement object to the API endpoint. Here is the image of API documentat

enter image description here

Just for editing of existing Service Agreement I have following Retrofit interface:

@PUT("/v3/service_agreement_setups/{id}")
Single<Response<Agreement>> editAgreement(@Path("id") Integer id, @Body AgreementRequest agreementRequest);

AgreemnetRequest has the following structure:

public class AgreementRequest {

 @Expose @SerializedName("service_agreement_setup") private Agreement  agreement;

public AgreementRequest(Agreement agreement) {
this.agreement = agreement;
}

public Agreement getAgreement() {
return agreement;
}

public void setAgreement(Agreement agreement) {
this.agreement = agreement;
}
}

So, as you can see inside Agreement class I should have signature_image field and upload image file.

How I can do that?

Zookey
  • 2,637
  • 13
  • 46
  • 80
  • You can use `@Part MultipartBody.Part` image in `Retrofit`. Just like [this thread](https://stackoverflow.com/questions/39953457/how-to-upload-image-file-in-retrofit-2) – M D Dec 17 '18 at 13:21
  • I have tried but MultiPart and Body can not go together. – Zookey Dec 17 '18 at 13:28
  • Both parts are multipart. The JSON and the image, two parts. – EpicPandaForce Dec 17 '18 at 13:52
  • How then I can set up an image inside JSON object? Can you explain with some code example? @EpicPandaForce – Zookey Dec 17 '18 at 14:36
  • I can comment from 50 xp and above. So I answer: [https://stackoverflow.com/questions/33338181/is-it-possible-to-show-progress-bar-when-upload-image-via-retrofit-2](https://stackoverflow.com/questions/33338181/is-it-possible-to-show-progress-bar-when-upload-image-via-retrofit-2) – Tranquillo Dec 17 '18 at 16:00

0 Answers0