Skip to content

Instantly share code, notes, and snippets.

@Audhil
Last active July 27, 2019 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Audhil/762018c4f071870351bbe04556f1975a to your computer and use it in GitHub Desktop.
Save Audhil/762018c4f071870351bbe04556f1975a to your computer and use it in GitHub Desktop.
val jsonObj = JsonObject()
jsonObj.addProperty("title", "rhythm")
jsonObj.addProperty("singer", "meee")
jsonObj.addProperty("text", "Jack and jill went up the hill to fetch a pail of water!")
// POST demo
APIKindaStuff
.service
.getVectors(jsonObj)
.enqueue(object : Callback<ResponseBody> {
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
println("---TTTT :: POST Throwable EXCEPTION:: " + t.message)
}
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
if (response.isSuccessful) {
val msg = response.body()?.string()
println("---TTTT :: POST msg from server :: " + msg)
Toast.makeText(applicationContext, msg, Toast.LENGTH_SHORT).show()
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment