I am using Retrofit 2.9.0 to send network requests:
val retrofit = Retrofit.Builder()
.baseUrl(BuildConfig.API_URL)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.build()
return retrofit.create(ApiService::class.java)
and Moshi 2.4.0 for JSON serialization:
Moshi.Builder().build()
I have some model with a next field which can be null:
data class ChangeDutyEvent(
@field:Json(name = "signature_date") var signatureDate: String? = null,
...
)
When I send PATCH request with some not null value of this field, it is working normaly - value updates on server. But when I send the same request with null value, its value on server is still not null. So, I think Retrofit or Moshi ignore null, how I can fix it?
question from:
https://stackoverflow.com/questions/65829444/how-to-send-patch-request-and-change-field-to-null 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…