title: Retrofit Uploading multiple images to a single key
body: <p>I am using Retrofit to upload images to my server. Here I need to upload multiple images for a single key. I have tried with Postman web client it is working well. Here is a screenshot.</p>
  
  <p><a href="https://i.stack.imgur.com/Nr0ZP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Nr0ZP.png" alt="enter image description here"></a></p>
  
  <p>Here are the key value pairs for the request.<br>
  <strong>SurveyImage    : [file1,file2,file3];<br>
  PropertyImage  : file<br>
  DRA            : jsonBody<br></strong>   </p>
  
  <p>I tried to do the same with Retrofit. but the images are not uploading to the server.Here is my code.<br>
  <strong>WebServicesAPI.java</strong></p>
  
  <pre><code>public interface WebServicesAPI {
      @Multipart
      @POST(WebServices.UPLOAD_SURVEY)
      Call&lt;UploadSurveyResponseModel&gt; uploadSurvey(@Part MultipartBody.Part surveyImage, @Part MultipartBody.Part propertyImage, @Part("DRA") RequestBody dra);
  }
  </code></pre>
  
  <p>Here is the method for uploading the files.</p>
  
  <pre><code> private void requestUploadSurvey() {
          File propertyImageFile = new File(surveyModel.getPropertyImagePath());
          RequestBody propertyImage = RequestBody.create(MediaType.parse("image/*"), propertyImageFile);
          MultipartBody.Part propertyImagePart = MultipartBody.Part.createFormData("PropertyImage", propertyImageFile.getName(), propertyImage);
          JSONObject requestBody = getRequestBody();
          RequestBody draBody = null;
          try {
              draBody = RequestBody.create(MediaType.parse("text/plain"), requestBody.toString(1));
              Log.d(TAG, "requestUploadSurvey: RequestBody : " + requestBody.toString(1));
          } catch (JSONException e) {
              e.printStackTrace();
          }
          MultipartBody.Builder builder = new MultipartBody.Builder();
          builder.setType(MultipartBody.FORM);
          MultipartBody surveyImage = null;
  
              for (SurveyModel.PictureModel model : surveyModel.getPicturesList()) {
                  File file = new File(model.getImagePath());
                  builder.addFormDataPart("SurveyImage", file.getName(),
                          RequestBody.create(MediaType.parse("image/*"), file));
              }
              surveyImage = builder.build();
  
          final WebServicesAPI webServicesAPI = RetrofitManager.getInstance().getRetrofit().create(WebServicesAPI.class);
          Call&lt;UploadSurveyResponseModel&gt; surveyResponse = null;
  
              surveyResponse = webServicesAPI.uploadSurvey(MultipartBody.Part.createFormData("SurveyImage", "SurveyImage", surveyImage), propertyImagePart, draBody);
  
          surveyResponse.enqueue(this);
  
          Log.d(TAG, "requestUploadSurvey: sent the request");
      }
  </code></pre>
  
  <p>Please help me with this. </p>