import java.io.IOException
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val MEDIA_TYPE = "application/json".toMediaType()
val requestBody = "{\"userId\":\"foo\",\"email\":\"foo@gmail.com\"}"
val request = Request.Builder()
.url("https://api.tggl.io/flags")
.post(requestBody.toRequestBody(MEDIA_TYPE))
.header("Content-Type", "application/json")
.header("x-tggl-api-key", "API_KEY")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
response.body!!.string()
}
Empower product and marketing teams to experiment within safe boundaries set by your engineering team.
Your app is instantly updated when a flag is updated, no need to write code and deploy the new version.