Basically, I've REST by Ktor in my android app. As remote data storage I'm using Back4App. When I send post method I have following message in ktor's logger:
REQUEST https://parseapi.back4app.com/classes/Feed failed with exception: java.util.concurrent.CancellationException: Job was cancelled
I don't manage coroutines logic in app, so I don't even understand why I keep getting this error.
By the way, when I use Insomnia to test method - everything is good. And when this error appears in app - app doesn't fall and keep ruuning.
So the question is: how to deal with that bug?
The code with request:
suspend fun addFeed(newFeedDto: FeedEntity): Result<Unit> = withContext(Dispatchers.IO) { runCatching { val response = client.post(BACK4APPURL) { contentType(ContentType.Application.Json) setBody( FeedDto( url1 = newFeedDto.url1, url2 = newFeedDto.url2, content = newFeedDto.content, nytUrl = newFeedDto.nytUrl, newsName = newFeedDto.newsName, newsPreview = newFeedDto.newsPreviewUrl, tags = newFeedDto.tags ) ) headers { append("X-Parse-Application-Id", **) append("X-Parse-REST-API-Key", **) } } if (response.status != HttpStatusCode.Created) error("Status ${response.status}") response.body() } }