question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.IllegalArgumentException: method GET must not have a request body.

See original GitHub issue

What kind of issue is this?

  • Question. This issue tracker is not the place for questions. If you want to ask how to do something, or to understand why something isn’t working the way you expect it to, use Stack Overflow. https://stackoverflow.com/questions/tagged/okhttp

  • Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests get fixed. Here’s an example: https://gist.github.com/swankjesse/981fcae102f513eb13ed

  • Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.

I’m trying to do a get request to Elasticsearch with a query body but OkHttp doesn’t allow that. The query works with curl:

curl -XGET 'localhost:9200/fncd/event/_search?scroll=1m' -d '
{
    "query": {
	    "range" : {
	        "lastUpdated" : {
	            "gte": 1486184400000
	        }
	    }
    }
}
'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:15
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

80reactions
swankjessecommented, Mar 18, 2017

It’s unlikely we’ll ever support request bodies with GET.

No further action to take on this.

54reactions
swankjessecommented, Jul 25, 2017

OkHttp is an opinionated HTTP client. By constraining what we support to what the specs allow, we’re able to keep things relatively simple and offer great features like smart caching.

Elasticsearch is wrong for exposing APIs that use GET requests with bodies. They should fix their API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GET request with request body in OkHttp - java - Stack Overflow
IllegalArgumentException : method GET must not have a request body. Request request = new Request.Builder() .url("http://example.com") ...
Read more >
okhttp3.Request.body java code examples - Tabnine
@Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); if (originalRequest.body() == null ...
Read more >
java.lang.IllegalArgumentException: method GET must not ...
【Java异常】Caused by: java.lang.IllegalArgumentException: method GET must not have a request body.
Read more >
okhttp/src/main/java/com/squareup/okhttp/Request.java
you may not use this file except in compliance with the License. ... throw new IllegalArgumentException("method " + method + " must have...
Read more >
OKHttp "method GET must not have a request body" 에러
오류 메세지 java.lang.IllegalArgumentException: method GET must not have a request body. 오류 발생 코드 val httpClient = OkHttpClient() val ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found