Stefan Oltmann
01/17/2022, 2:03 PMvar delta: DropboxDelta = post("$DROPBOX_API_URL/files/list_folder") {
contentType(ContentType.Application.Json)
body = Parameters.build {
append("path", "/")
append("recursive", "true")
append("include_non_downloadable_files", "false")
}.formUrlEncode()
}
Client request(https://api.dropboxapi.com/2/files/list_folder) invalid: 400 Bad Request. Text: "Error in call to API function "files/list_folder": request body: expected object, got string"
For OAuth I can use this construct:
return tokenClient.submitForm(
url = tokenUrl,
formParameters = Parameters.build {
append("grant_type", "authorization_code")
append("code", authorizationCode)
append("client_id", clientId)
}
)
But that does not work with list_folder
Can someone share an example how to do this?var delta: DropboxDelta = post("$DROPBOX_API_URL/files/list_folder") {
contentType(ContentType.Application.Json)
body = DropboxDeltaRequest()
}
@Serializable
data class DropboxDeltaRequest(
@Required
val path: String = "",
@Required
val recursive: Boolean = true,
@Required
@SerialName("include_non_downloadable_files")
val includeNonDownloadableFiles: Boolean = false
)
I hope that saves someone else time.
Ktor doc really has a lot of potential for improvement.