Skip to content

Commit

Permalink
Merge pull request #112 from Infomaniak/fix-request-body-with-json
Browse files Browse the repository at this point in the history
fix: Add JSON Content-Type for custom post body
  • Loading branch information
tevincent authored Dec 6, 2024
2 parents f16feee + 02a4d1f commit 4913737
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import io.ktor.client.HttpClient
import io.ktor.client.plugins.onUpload
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import io.ktor.http.ContentType
import io.ktor.http.contentType
import io.ktor.http.isSuccess
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
Expand All @@ -47,6 +49,7 @@ internal class UploadRequest(json: Json, httpClient: HttpClient) : BaseRequest(j

suspend fun resendEmailCode(resendEmailCodeBody: ResendEmailCodeBody): Boolean {
val httpResponse = httpClient.post(url = createUrl(ApiRoutes.resendEmailCode)) {
contentType(ContentType.Application.Json)
setBody(resendEmailCodeBody)
}
return httpResponse.status.isSuccess()
Expand Down Expand Up @@ -77,6 +80,7 @@ internal class UploadRequest(json: Json, httpClient: HttpClient) : BaseRequest(j

suspend fun cancelUpload(jsonBody: JsonObject): Boolean {
val httpResponse = httpClient.post(url = createUrl(ApiRoutes.cancelUpload)) {
contentType(ContentType.Application.Json)
setBody(jsonBody)
}
return httpResponse.status.isSuccess()
Expand Down

0 comments on commit 4913737

Please sign in to comment.