Hi folks. I am new to KMM and trying to create a g...
# multiplatform
m
Hi folks. I am new to KMM and trying to create a generic function for api calling using ktor with 
reified
  and it seems to work fine with 
android
 but throws an error in 
iOS
This is my common api call return in Shared file.
Copy code
@Throws(Exception::class)
suspend inline fun<reified T> post(url: String, requestBody: HashMap<String, Any>?) : Either<CustomException, T> {
    try {
        val response = <http://httpClient.post|httpClient.post><T> {
            url(BASE_URL.plus(url))
            contentType(ContentType.Any)
            if (requestBody != null) {
                body = requestBody
            }
            headers.remove("Content-Type")
            headers {
                append("Content-Type", "application/json")
                append("Accept", "application/json")
                append("Time-Zone", "+05:30")
                append("App-Version", "1.0.0(0)")
                append("Device-Type", "0")
            }
        }
        return Success(response)
    }  catch(e: Exception) {
        return Failure(e as CustomException)
    }
}
It works good in android if I call it like this :-
Copy code
<http://api.post|api.post><MyDataClassHere>(url = "url", getBody()).fold(
    {
        handleError(it)
    },
    {
        Log.d("Success", it.toString())
    }
)
But I am not able to get it run on iOS devices it shows me error like this :- `some : Error Domain=KotlinException Code=0 "unsupported call of reified inlined function `com.example.myapplication.shared.apicalls.SpaceXApi.post`" UserInfo={NSLocalizedDescription=unsupported call of reified inlined function
<http://com.example.myapplication.shared.apicalls.SpaceXApi.post|com.example.myapplication.shared.apicalls.SpaceXApi.post>
, KotlinException=kotlin.IllegalStateException: unsupported call of reified inlined function
<http://com.example.myapplication.shared.apicalls.SpaceXApi.post|com.example.myapplication.shared.apicalls.SpaceXApi.post>
, KotlinExceptionOrigin=}` Any help in this is appreciated. Thanks