Hi, I am new to Kotlin. I have an API expected req...
# getting-started
s
Hi, I am new to Kotlin. I have an API expected request like this:
Copy code
@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:
Copy code
{
  "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
Any chance the error is coming from elsewhere, or one of the data objects like CartOTCItem?
☝️ 1
g
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
@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.