Skip to main content

Upload Consultation Attachments

Upload Consultation Attachments Example​

mediaIDs can only be sent while creating the consultation. To attach files after that, upload them with uploadMedia and pass the returned ids to uploadConsultationAttachments.

ApiService.uploadConsultationAttachments(
consultationId: String,
mediaIDs: List<String>,
callback: ApiCallback<Boolean>
)

consultationId is the consultation id, and mediaIDs are ids returned by uploadMedia

Send only the newly uploaded ids. Re-sending ids that are already attached is treated as a duplicate request

Passing an empty mediaIDs list throws an exception before the request is sent

Check the example

import com.altibbi.telehealth.ApiService
import com.altibbi.telehealth.ApiCallback
import com.altibbi.telehealth.model.Media
import java.io.File

fun attachFile(file: File, consultationId: String) {
ApiService.uploadMedia(file, object : ApiCallback<Media> {
override fun onSuccess(response: Media) {
val mediaId = response.id ?: return
ApiService.uploadConsultationAttachments(
consultationId,
listOf(mediaId),
object : ApiCallback<Boolean> {
override fun onSuccess(response: Boolean) {
// Call getConsultationInfo to refresh the media list of the consultation
}

override fun onFailure(error: String?) {
}

override fun onRequestError(error: String?) {
}
}
)
}

override fun onFailure(error: String?) {
}

override fun onRequestError(error: String?) {
}
})
}

onSuccess returns true when the attachments are added. The updated media list is not part of the response, so call getConsultationInfo if you need to show it

Responses​

Status 200​

Success

{
"media_ids": ["3f1c7b2e-9d4a-4f2b-8c11-0a2d5e6f7a80"]
}

Status 401​

UnauthorizedHttpException represents an Unauthorized HTTP exception with status code 401

{
"name": "Unauthorized",
"message": "Your request was made with invalid credentials",
"code": "0",
"status": "401",
"type": "yii\\web\\UnauthorizedHttpException"
}

Status 403​

Duplicate request

{
"name": "Forbidden",
"message": "duplicate request OR Current user cant access this page",
"code": "0",
"status": "403",
"type": "yii\\web\\ForbiddenHttpException"
}

Status 404​

Consultation id invalid or consultation deleted

{
"name": "Not Found",
"message": "Object not found",
"code": "0",
"status": "404",
"type": "yii\\web\\NotFoundHttpException"
}

Status 422​

Data Validation Failed

[
{
"field": "string",
"message": "string"
}
]