I have photo and that photo can have comments (optional) and I need to upload both photo and comment if there is some. I am using POST with Multipart for image uploading, but I do not know how to add photo comment to the API.
Here what I have for Retrofit interface:
@Multipart
@POST("/v3/work_orders/{work_order_id}/photo_attachments")
Single<Response<ResponseBody>> uploadPhoto(
@Path("work_order_id") int workOrderId,
@Part MultipartBody.Part imageBody);
Here is how I send data to that Retrofit interface:
@Override public Single<Response<ResponseBody>> uploadPhoto(
int workOrderId, PhotoAttachmentRequest photoAttachmentRequest
) {
RequestBody requestFile = RequestBody.create(MediaType.parse("image/png"), photoAttachmentRequest.getAttachment());
MultipartBody.Part imageBody = MultipartBody.Part.createFormData(
"photo_attachment[attachment]",
photoAttachmentRequest.getAttachment().getName(),
requestFile
);
return api.uploadPhoto(workOrderId, imageBody)
.subscribeOn(Schedulers.io());
}
How I can send also photo_attachement[comments] field?