https://kotlinlang.org logo
Title
s

Serena Xu

04/05/2022, 2:11 AM
Hi, I am new to Kotlin. I have an API expected request like this:
@Json(name = "order_id") val orderId: Int,
@Json(name = "new_delivery_window_id") val newDeliveryWindowId: Int?,
@Json(name = "new_delivery_window_uuid") val newDeliveryWindowUUID: UUID?,
@Json(name = "new_delivery_address_id") val newDeliveryAddressId: Int?,
@Json(name = "otc_items") val otcItems: List<CartOTCItem>?,
@Json(name = "fills") val fills: List<PrescriptionFulfillment>?,
@Json(name = "promo_items") val promoItems: List<PromoItem>?,
@Json(name = "reason") val reason: String?,
@Json(name = "note") val note: String?,
@Json(name = "subtotal") val subtotal: Int?
My payload is:
{
  "order_id": 980,
  "new_delivery_window_id": 14,
  "new_delivery_window_uuid": "8d",
  "new_delivery_address_id": 136,
  "note": "testing note",
  "subtotal": 1000,
  "reason": "testing reason"
}
I got error:
com.squareup.moshi.JsonDataException: Expected an int but was NULL at path $.createdBy
. I am a bit confused of
createdBy
. Anyone has any clues on this ?
r

Richard Gomez

04/05/2022, 3:01 AM
Any chance the error is coming from elsewhere, or one of the data objects like CartOTCItem?
☝️ 1
g

G.E.N.T.L.E.K.B.O.Y

04/05/2022, 7:24 AM
I'm guessing the "createdBy" field is set to type of Int. Meanwhile, what is being received from the server is null. If you do find where the "createdBy" field is, making it nullable should solve this issue.
s

Serena Xu

04/05/2022, 1:39 PM
@Richard Gomez createdBy doesn’t come from API expected request body. It is in other API request body though. I am not sure if that is the reason.