I found a youtube video on how to do a get url but I need to do a post to a REST api. I am unsure on how to do so.
Ive tried to look around on here but most of it is java.
fun fetchJson() {
println ("attempting to fetch JSON")
val url = "https://utgapi.shift4test.com/api/rest/v1/transactions/sale"
val request = Request.Builder().url(url).build()
val client = OkHttpClient()
client.newCall(request).enqueue(object: Callback {
override fun onResponse(call: Call?, response: Response?) {
val body = response?.body()?.string()
println(body)
println("try and get json api working there was an error")
}
override fun onFailure(call: Call, e: IOException) {
println("failed to execute request")
}
with the GET i just receive a error because i am not doing a POST request.