Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7742549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:18:13+00:00 2026-06-01T09:18:13+00:00

Using cURL I can send a GET request with a body. Example: curl -i

  • 0

Using cURL I can send a GET request with a body. Example:

curl -i -X GET http://localhost:8081/myproject/someController/l2json -H "content-type: application/json" -d "{\"stuff\":\"yes\",\"listThing\":[1,2,3],\"listObjects\":[{\"one\":\"thing\"},{\"two\":\"thing2\"}]}"

Here is the JSON in a reasonable format for legibility’s sake:

{"stuff":"yes",
"listThing":[1,2,3],
"listObjects":[{"one":"thing"},{"two":"thing2"}]}

Normally -d will tell cURL to send a POST but I have confirmed that the -X GET is overriding that and it is sending GET. Is it possible to replicate this with HTTPBuilder?

I have done:

def http = new HTTPBuilder( 'http://localhost:8081/' )

http.post(path:'/myproject/myController/l2json', body:jsonMe, requestContentType:ContentType.JSON) { resp ->
  println "Tweet response status: ${resp.statusLine}"
  assert resp.statusLine.statusCode == 200
}

Which works, but if I change .post to .get I get the error:

Cannot set a request body for a GET method. Stacktrace follows:
Message: Cannot set a request body for a GET method
Line | Method
->> 1144 | setBody              in groovyx.net.http.HTTPBuilder$RequestConfigDelegate

Is there a way to send a GET with a request body using HTTPBuilder?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:18:14+00:00Added an answer on June 1, 2026 at 9:18 am

    Short answer: No.

    Long answer: The HTTPBuilder doesn’t let you set the HTTP method for a request at any time other than when actually creating a request.
    Parameters are also set at creating by a closure which checks the type of request and throws that exception if the request is not of type HttpEntityEnclosingRequest.

    You can check the source code here: https://fisheye.codehaus.org/browse/gmod/httpbuilder/trunk/src/main/java/groovyx/net/http/HTTPBuilder.java?hb=true

    On a side note, the HTTP 1.1 spec doesn’t say outright that a GET can’t have a body, but it says that if a request semantics doesn’t allow one, then it must not be provided, and that servers receiving such requests should ignore it.

    Since most people are used to that convention, I would suggest sticking with it, and not having your service actually make use of the body when sending a GET request.

    See also this question: HTTP GET with request body

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Curl for example, I can "post" data (send an entity-body) in a GET
I'm transferring files from an existing http request using cURL like so... $postargs =
I'm using http://www.barattalo.it/2010/08/09/send-push-notification-to-iphone-with-php-and-pushme-to/ When i call the function i get the error messages. Notice:
How can I send a double quote char using curl.exe in the -d parameter.
I am using couchDB to get a UUID so that I can send a
How can I upload files to a HTTPS site using CURL? The site is
How can I do a RAW POST in PHP using cURL? Raw post as
I'm setting a CURL authentication, using CURLOPT_USERPWD: curl_setopt($curl_handle, CURLOPT_USERPWD, $login); // Authenticate How can
I'm using cURL to get the XML file for my Twitter friend's timeline. (API
I am trying to send username and password parameters to a url using curl,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.