I have been tyring to execute API has two parameters as I said in title
here is my API configure
//region SignUp
String SIGN_UP_USER = "User/SignUp";
@POST(SIGN_UP_USER)
@Multipart
@Headers("Content-Type: application/json")
Call<SignUpResponse> signUp(
@Part MultipartBody.Part profilePicture,
@Query("email") String email,
@Query("password") String password,
@Query("firstName") String firstName,
@Query("lastName") String lastName);
//endregion
But when I execute the request I got this error:
java.lang.IllegalStateException: Multipart body must have at least one part.
And here is the details of request from Swagger
Any suggestions for this issue,
Thanks in advance
3
Answers
All what I did to fix my problem was remove this Annotation
from my code and request.
and for sending empty files you can just send a null parameter for file will take it as empty.
You can use
@Part("email") RequestBody email,
rather than@Query
.Try the below way. [I’m using Kotlin].
Create Multipart Body Object
Pass the builder to your signup method.
Do not use multipart annotation.
Hope this will help you.