You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android App通过Post API提交单个字符/表情时触发422错误无法入库

问题:提交单个字符或表情时返回422 Unprocessable Content错误

我正在开发一款支持用户发布文本、图片或视频的Android应用,整体功能运行正常,但当提交单个字符或表情时,会返回422 Unprocessable Content错误。错误详情如下:

ERROR:: Response{protocol=http/1.1, code=422, message=Unprocessable Content, url=http://myUrl.com}

RetrofitBuilder 代码

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接口代码

@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>

内容的提问来源于stack exchange,提问作者monjur

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 08:40:40