this code works:
val rbody1: RequestBody = FormBody.Builder()
.add("username", "100")
.add("password", "123test123")
.build()
requestBuilder = Request.Builder()
.url(url)
.post(rbody2)
etc...
But I want to be able to pass a JSON string rather than having to encode each json parameter by hand.
val json = "{\"username\":100,\"password\":\"123test123\"}"
//completely fails, this is a okhttp3.RequestBody$Companion$toRequestBody$2
val MIMEType= "application/json".toMediaType()
val rbody2 = json.toRequestBody(MIMEType)
If I pass the rbody2 to the Request.Builder it fails. And I see no way to convert rbody2 to a FormBody, nor do I see a way to pass a json string into FormBody.Builder
This link does not answer my question: OkHttp Post Body as JSON