How can i upload image file along with my json.
My request JSON looks in the below format.
{
"Request": {
"first_name": "Josmy",
"last_name": "J",
"profile_image_attributes": {
"image":"file"
}
}
}
In my gson class i am inputting values some what like this
public class Request implements Serializable {
@SerializedName("first_name")
private String firstName;
@SerializedName("last_name")
private String lastName;
@SerializedName("profile_image_attributes")
private MultipartBody.Part profileImageAttributes;
}
@Headers("Content-Type:application/json")
@POST(PSDApiconstants.REGISTRATION)
Observable<PSDSignUpResponseBean> registration(@Body PSDRegistrationRequestBean requestBean);
is there any way without changing the request to
{
"imag": "File",
"first_name": "Josmy",
"last_name": "J",
}
EDIT
Currently I think retrofit 2.0.1 dosen't support image upload in this pattern. so i use Asynchttp to solve this problem. But may be retrofit 2 will include this in their latest release by the end of july