From dbb17b16776a5ee6f30df8d26a1412f08b47962a Mon Sep 17 00:00:00 2001 From: Philippe Weidmann Date: Thu, 12 Dec 2024 13:43:49 +0100 Subject: [PATCH] feat(UploadRequest): Remove null keys encode to json --- .../network/requests/UploadRequest.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt index 9a7c0c41..f5954272 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt @@ -36,11 +36,16 @@ import io.ktor.http.contentType import io.ktor.http.isSuccess import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.encodeToJsonElement internal class UploadRequest(json: Json, httpClient: HttpClient) : BaseRequest(json, httpClient) { suspend fun initUpload(initUploadBody: InitUploadBody): InitUploadResponseApi { - return post(url = createUrl(ApiRoutes.initUpload), initUploadBody) + val nullableJson = Json(json) { + explicitNulls = false + } + val encodedInitUploadBody = nullableJson.encodeToJsonElement(initUploadBody) + return post(url = createUrl(ApiRoutes.initUpload), encodedInitUploadBody) } suspend fun verifyEmailCode(verifyEmailCodeBody: VerifyEmailCodeBody): AuthorEmailToken {