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.

httpGet can't send body in request

See original GitHub issue

I’m creating an android app using Fuel for kotlin and i need to send a GET request to the server with a body but got “Exception : method does not support a request body: GET”. How can I send a body with my GET request ?

I follow you my function:

fun getFunc (data: JSONObject, url : String): String {
    lateinit var ret : String

    thread {
        FuelManager.instance.basePath = "https://blih.epitech.eu"
        Fuel.upload(url, Method.GET)
            .source { _, _ -> File.createTempFile(".temp", ".tmp") }
            .body(data.toString().toByteArray())
            .header("Content-Type" to "application/json")
            .response { request, response, result ->
                val (bytes, error) = result
                if (bytes != null) {
                    println("[response bytes] ${String(bytes)}")
                }
                ret = response.toString()
                println("error: $error")
            }
    }
    Thread.sleep(1000)
    return ret
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
wfxrcommented, Mar 23, 2020

Not allow to send body in GET request is a strange restriction. As @SleeplessByte said that unreasonable constraint was already dropped from the RFC. Meanwhile many famous projects’ apis take body in GET request (Elasticsearch for example).

GET /_search
{
  "query": {
    "multi_match": {
      "query": "this is a test",
      "fields": [
        "subject",
        "message"
      ]
    }
  }
}

So will fuel plan to remove the restriction? Otherwise we have to use POST method to get something when the query is complicated (hope luckily the server support both post and get).

0reactions
SleeplessBytecommented, Aug 29, 2021

Hi @emanuele-dedonatis . Unfortunately we’re still constraint by the underlying HTTP library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to send request body in Http GET method on angular 10
Our api server need empty request body object in GET request. I want like this { method: 'get', url: 'http://domain.api.com/api/method?param1= ...
Read more >
Request bodies in GET requests - Evert Pot
Yes. In other words, any HTTP request message is allowed to contain a message body, and thus must parse messages with that in...
Read more >
What is HTTP GET Request Method? - ReqBin
No, HTTP GET requests cannot have a message body. But you still can send data to the server using the URL parameters. In...
Read more >
is there anyway to send body request with get method?
No, We cannot send Body with GET Method. The Purpose of GET is to retrieve data. If i take example of database then...
Read more >
Communicating with backend services using HTTP - Angular
For all HttpClient methods, the method doesn't begin its HTTP request until ... and causes HttpClient to compose and send the HTTP request...
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