If you want to send the phone
as a query parameter, you should add it to the request URL, not to the request body. You don't need to specify the method: GET is the default. By the way, you can get rid of the Content-type
header (GET requests, usually, have no content):
val url = weburl.toHttpUrl().newBuilder()
.addQueryParameter("phone", phone)
.build()
val request = Request.Builder().url(url)
.header("User-Agent", "OkHttp Headers.java")
.header("Accept", "application/json")
.build()
If your requirement is to send a GET request with a request body, than you are out of luck I'm afraid: OkHttp does not support it. Anyways, most likely, it's not what you want (unless you are calling Elasticsearch API...)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…