java - GET request with request body in OkHttp -


i'm trying use okhttp 3.6.0 elasticsearch , i'm stuck sending requests elasticsearch multi api.

it requires sending http request request body. unfortunately okhttp doesn't support out of box , throws exception if try build request myself.

requestbody body = requestbody.create("text/plain", "test");  // no requestbody supported request request = new request.builder()                   .url("http://example.com")                   .get()                   .build();  // throws: java.lang.illegalargumentexception: method must not have request body. request request = new request.builder()                   .url("http://example.com")                   .method("get", requestbody)                   .build(); 

is there chance build request request body in okhttp?

related questions:


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -