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 8796301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:35:28+00:00 2026-06-13T23:35:28+00:00

Possible Duplicate: HTTP GET with request body I’ve read few discussions here which do

  • 0

Possible Duplicate:
HTTP GET with request body

I’ve read few discussions here which do not advocate sending content via HTTP GET. There are restrictions on the size of data that can be sent via clients (web browsers). And handling GET data also depends on servers. Please refer section Resources below.

However, I’ve been asked to test the possibility to send content via HTTP GET using RestTemplate. I refered few discussions on spring forum but they were not answered. (Please note sending data via http Post works fine). The discussion here suggests using POST instead.

dev env – JBoss AS 5.1, Spring 3.1.3

Client

    @Test
public void testGetWithBody()
{
    // acceptable media type
    List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
    acceptableMediaTypes.add(MediaType.TEXT_PLAIN);

    // header
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(acceptableMediaTypes);

    // body
    String body = "hello world";
    HttpEntity<String> entity = new HttpEntity<String>(body, headers);

    Map<String, Object> uriVariables = new HashMap<String, Object>();
    uriVariables.put("id", "testFile");

    // Send the request as GET
    ResponseEntity<String> result = restTemplate.exchange(
            "http://localhost:8080/WebApp/test/{id}/body",
            HttpMethod.GET, entity, String.class, uriVariables);

    Assert.assertNotNull(result.getBody());
}

Server @Controller

    @RequestMapping(value = "/{id}/body", method = RequestMethod.GET)
public @ResponseBody
String testGetWithBody(@PathVariable String id,
        @RequestBody String bodyContent)
{
    return id + bodyContent;
}

The problem –
executing this test case returns 500 Internal Server Error. On debugging, I found that the controller is not hit.

  1. Is it correct to understand that the RestTemplate provides the way to send data as request body, but the error occurs because the server could not handle the request body ?

  2. If the request body sent via HTTP Get is not conventional why does RestTemplate provide the APIs to allow sending it ? Does this mean there are few servers capable of handling the Request body via GET ?

Resources – discussions on sending body via HTTP GET using RestTemplate at spring forum

http://forum.springsource.org/showthread.php?129510-Message-body-with-HTTP-GET&highlight=resttemplate+http+get

http://forum.springsource.org/showthread.php?94201-GET-method-on-RestTemplate-exchange-with-a-Body&highlight=resttemplate+http+get

Resources – General discussions on sending body via HTTP GET

get-with-request-body

is-this-statement-correct-http-get-method-always-has-no-message-body

get-or-post-when-reading-request-body

http-uri-get-limit

  • 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-13T23:35:29+00:00Added an answer on June 13, 2026 at 11:35 pm

    Is it correct to understand that the RestTemplate provides the way to send data as request body, but the error occurs because the server could not handle the request body ?

    You can tell by looking at network traffic (does the request get sent with a request body and a GET method?) and at server logs (the 500 result you receive must have a server-side effect that gets logged, and if not, configure the server to do so).

    If the request body sent via HTTP Get is not conventional why does RestTemplate provide the APIs to allow sending it ? Does this mean there are few servers capable of handling the Request body via GET ?

    Because it is a generic class that also allows you to craft requests that can include a message body.

    As stated in HTTP GET with request body:

    In other words, any HTTP request message is allowed to contain a message body, and thus [a server] must parse messages with that in mind. Server semantics for GET, however, are restricted such that a body, if any, has no semantic meaning to the request. The requirements on parsing are separate from the requirements on method semantics.

    A body on a GET cannot do anything semantically, because you are requesting a resource. It’s like you tell the server: “Give me resource X, oh, and have some apples!”. The server won’t care about your apples and happily serve resource X – or throw an error because it doesn’t like any offers in a request.

    However, I’ve been asked to test the possibility to send content via HTTP GET

    Please tell the one who requested this that this is a case that should not have to be tested, because no sensible implementation supports it.

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

Sidebar

Related Questions

Possible Duplicate: php/html - http_referer I want to find which page/script get request to
Possible Duplicate: maximum length of HTTP GET request? how many characters can be sent
Possible Duplicate: How can I make an HTTP GET request from Perl? I am
Possible Duplicate: What's the correct encoding of HTTP get request strings? One of my
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: Client-side detection of HTTP request method I'm working on Javascript that is
Possible Duplicate: Cross-Domain Requests with jQuery $(function () { (function getFeed() { $ .get('http://feeds.bbci.co.uk/news/world/rss.xml')
Possible Duplicate: What’s wrong with my PHP curl request, please help .. I’m not
Possible Duplicate: Converting Raw HTTP Request into HTTPWebRequest Object I've got a custom HTTP
Possible Duplicate: Why do I get “Cannot redirect after HTTP headers have been sent”

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.