I am developing an app where users can post text, img or video. Everything working fine. But sometimes it's giving me the error Unprocessable Content
, when I want to post a single letter or emoji.
ERROR:: Response{protocol=http/1.1, code=422, message=Unprocessable Content, url=http://myUrl.com}
My RetrofitBuiler Object:
var gson: Gson = GsonBuilder()
.setLenient()
.setDateFormat("yyyy-MM-dd hh:mm:ss.S")
.create()
private var httpClient =
OkHttpClient.Builder().retryOnConnectionFailure(true).connectTimeout(60, TimeUnit.SECONDS)
.build()
private val retrofit: Retrofit by lazy {
Retrofit.Builder().baseUrl(getBaseUrl())
.addConverterFactory(GsonConverterFactory.create(gson))
.addConverterFactory(NullConvertfactory()).client(httpClient).build()
}
val API_SERVICE: FansApiService by lazy {
retrofit.create(FansApiService::class.java)
}
APi InterFace:
@Headers("Accept:application/json")
@Multipart
@POST("endurlHere")
fun createPost(
@Header("Authorization") token: String,
@Part("text_content") text_content: RequestBody,
@Part imageList: List<MultipartBody.Part>
): Call<CreatePostResponse>