GET call with request body - request body not accessible at controller





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?



@GET
@Path("path")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Response getResponse(String requestBody) throws IOException { }


When I replaced @GET with @POST, requestBody has value. For GET call do we need to add anything more?










share|improve this question























  • I'd recommend you to take a look at: stackoverflow.com/a/983458/4934937

    – maio290
    Jan 3 at 10:09











  • @maio290 The link doesn't show how to get it resolved. It is sharing the ethics of passing request body in GET calls

    – vineeth
    Jan 3 at 10:41


















2















I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?



@GET
@Path("path")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Response getResponse(String requestBody) throws IOException { }


When I replaced @GET with @POST, requestBody has value. For GET call do we need to add anything more?










share|improve this question























  • I'd recommend you to take a look at: stackoverflow.com/a/983458/4934937

    – maio290
    Jan 3 at 10:09











  • @maio290 The link doesn't show how to get it resolved. It is sharing the ethics of passing request body in GET calls

    – vineeth
    Jan 3 at 10:41














2












2








2








I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?



@GET
@Path("path")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Response getResponse(String requestBody) throws IOException { }


When I replaced @GET with @POST, requestBody has value. For GET call do we need to add anything more?










share|improve this question














I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?



@GET
@Path("path")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Response getResponse(String requestBody) throws IOException { }


When I replaced @GET with @POST, requestBody has value. For GET call do we need to add anything more?







java spring rest






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 10:05









vineethvineeth

1389




1389













  • I'd recommend you to take a look at: stackoverflow.com/a/983458/4934937

    – maio290
    Jan 3 at 10:09











  • @maio290 The link doesn't show how to get it resolved. It is sharing the ethics of passing request body in GET calls

    – vineeth
    Jan 3 at 10:41



















  • I'd recommend you to take a look at: stackoverflow.com/a/983458/4934937

    – maio290
    Jan 3 at 10:09











  • @maio290 The link doesn't show how to get it resolved. It is sharing the ethics of passing request body in GET calls

    – vineeth
    Jan 3 at 10:41

















I'd recommend you to take a look at: stackoverflow.com/a/983458/4934937

– maio290
Jan 3 at 10:09





I'd recommend you to take a look at: stackoverflow.com/a/983458/4934937

– maio290
Jan 3 at 10:09













@maio290 The link doesn't show how to get it resolved. It is sharing the ethics of passing request body in GET calls

– vineeth
Jan 3 at 10:41





@maio290 The link doesn't show how to get it resolved. It is sharing the ethics of passing request body in GET calls

– vineeth
Jan 3 at 10:41












4 Answers
4






active

oldest

votes


















2














There are two ways for sending parameters in an Http Get method. PathVariable and RequestParam. In this way, sent parameters are visible in the request URL. for example:



www.sampleAddress.com/countries/{parameter1}/get-time?city=someValues


In the above request, parameter1 is a path variable and parameter2 is a request parameter. So an example of a valid URL would be:



www.sampleAddress.com/countries/Germany/get-time?city=berlin


To access these parameters in a java controller, you need to define a specific name for the parameters. For example the following controller will receive this type of requests:



@GetMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCities(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city
){
return "the method is not implemented yet";
}


You are able to send RequestBody through a Get request but it is not recommended according to this link.




yes, you can send a body with GET, and no, it is never useful
to do so.




This elaboration in elasticsearch website is nice too:




The HTTP libraries of certain languages (notably JavaScript) don’t allow GET requests to have a request body. In fact, some users are suprised that GET requests are ever allowed to have a body.



The truth is that RFC 7231—the RFC that deals with HTTP semantics and
content—does not define what should happen to a GET request with a
body! As a result, some HTTP servers allow it, and some—especially
caching proxies—don’t.




If you want to use Post method, you are able to have RequestBody too. In the case you want to send data by a post request, an appropriate controller would be like this:



@PostMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCitiesByPost(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city,
@RequestBody Object myCustomObject

){
return "the method is not implemented yet";
}


myCustomObject could have any type of data you defined in your code. Note that in this way, you should send request body as a Json string.






share|improve this answer


























  • you can send body with GET method too, but it's ignored for most cases.

    – Murat Güvenç
    Jan 3 at 11:02











  • @hamid from some other links, I can see, via GET call we can pass RequestBody too. See stackoverflow.com/a/983458/4934937

    – vineeth
    Jan 3 at 11:03













  • @MuratGüvenç This is not a standard way and I suggest to prevent that.

    – hamid ghasemi
    Jan 3 at 11:04






  • 1





    @hamidghasemi Yea... Got it..

    – vineeth
    Jan 3 at 11:18






  • 1





    Some HTTP servers allow it, and some—especially caching proxies—don’t. We tried a POC with Tomcat on which we passed the requestBody successfully. But when we tried the same with Weblogic( which is a caching proxies server), we were not able to succeed.

    – vineeth
    Jan 4 at 4:37



















3















I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?




One thing you are missing is the fact that the semantics of a request body with GET are not well defined.



RFC 7231, Section 4.3.1:




A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.







share|improve this answer
























  • By rejecting request you meant rejecting requestBody right? Because I am able to hit the my controller with the request but the requestBody is empty

    – vineeth
    Jan 3 at 11:09













  • @vineeth to quote from the old c++ standards newsgroup: "not defined" = "could make demons fly out of your nose". So any action the server or framework takes would be seen as ok. Be it rejecting the request, ignoring the body or using the body.

    – jokster
    Jan 3 at 12:57



















2














put @RequestBody on String requestBody parameter






share|improve this answer
























  • I have tried that. But still same result

    – vineeth
    Jan 3 at 10:39













  • I can actually confirm that this is working with springBoot 2.1.1.RELEASE.

    – maio290
    Jan 3 at 11:07



















2














@RequestMapping("/path/{requestBody}")
public Response getResponse(@PathVariable String requestBody) throws IOException { }





share|improve this answer
























  • It would be nice to add some details to this code. Why those annotation ?

    – AxelH
    Jan 3 at 10:16













  • @mkjh my requirement is pass the details in requestBody rather than requestParameter/PathVariable

    – vineeth
    Jan 3 at 10:43











  • @vineeth but requestbody is for POST. You should be using Uri for GET request

    – mkjh
    Jan 3 at 11:02











  • @mkjh See the link provided by maio290 above. GET calls too supports body

    – vineeth
    Jan 3 at 11:05












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020054%2fget-call-with-request-body-request-body-not-accessible-at-controller%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























4 Answers
4






active

oldest

votes








4 Answers
4






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














There are two ways for sending parameters in an Http Get method. PathVariable and RequestParam. In this way, sent parameters are visible in the request URL. for example:



www.sampleAddress.com/countries/{parameter1}/get-time?city=someValues


In the above request, parameter1 is a path variable and parameter2 is a request parameter. So an example of a valid URL would be:



www.sampleAddress.com/countries/Germany/get-time?city=berlin


To access these parameters in a java controller, you need to define a specific name for the parameters. For example the following controller will receive this type of requests:



@GetMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCities(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city
){
return "the method is not implemented yet";
}


You are able to send RequestBody through a Get request but it is not recommended according to this link.




yes, you can send a body with GET, and no, it is never useful
to do so.




This elaboration in elasticsearch website is nice too:




The HTTP libraries of certain languages (notably JavaScript) don’t allow GET requests to have a request body. In fact, some users are suprised that GET requests are ever allowed to have a body.



The truth is that RFC 7231—the RFC that deals with HTTP semantics and
content—does not define what should happen to a GET request with a
body! As a result, some HTTP servers allow it, and some—especially
caching proxies—don’t.




If you want to use Post method, you are able to have RequestBody too. In the case you want to send data by a post request, an appropriate controller would be like this:



@PostMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCitiesByPost(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city,
@RequestBody Object myCustomObject

){
return "the method is not implemented yet";
}


myCustomObject could have any type of data you defined in your code. Note that in this way, you should send request body as a Json string.






share|improve this answer


























  • you can send body with GET method too, but it's ignored for most cases.

    – Murat Güvenç
    Jan 3 at 11:02











  • @hamid from some other links, I can see, via GET call we can pass RequestBody too. See stackoverflow.com/a/983458/4934937

    – vineeth
    Jan 3 at 11:03













  • @MuratGüvenç This is not a standard way and I suggest to prevent that.

    – hamid ghasemi
    Jan 3 at 11:04






  • 1





    @hamidghasemi Yea... Got it..

    – vineeth
    Jan 3 at 11:18






  • 1





    Some HTTP servers allow it, and some—especially caching proxies—don’t. We tried a POC with Tomcat on which we passed the requestBody successfully. But when we tried the same with Weblogic( which is a caching proxies server), we were not able to succeed.

    – vineeth
    Jan 4 at 4:37
















2














There are two ways for sending parameters in an Http Get method. PathVariable and RequestParam. In this way, sent parameters are visible in the request URL. for example:



www.sampleAddress.com/countries/{parameter1}/get-time?city=someValues


In the above request, parameter1 is a path variable and parameter2 is a request parameter. So an example of a valid URL would be:



www.sampleAddress.com/countries/Germany/get-time?city=berlin


To access these parameters in a java controller, you need to define a specific name for the parameters. For example the following controller will receive this type of requests:



@GetMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCities(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city
){
return "the method is not implemented yet";
}


You are able to send RequestBody through a Get request but it is not recommended according to this link.




yes, you can send a body with GET, and no, it is never useful
to do so.




This elaboration in elasticsearch website is nice too:




The HTTP libraries of certain languages (notably JavaScript) don’t allow GET requests to have a request body. In fact, some users are suprised that GET requests are ever allowed to have a body.



The truth is that RFC 7231—the RFC that deals with HTTP semantics and
content—does not define what should happen to a GET request with a
body! As a result, some HTTP servers allow it, and some—especially
caching proxies—don’t.




If you want to use Post method, you are able to have RequestBody too. In the case you want to send data by a post request, an appropriate controller would be like this:



@PostMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCitiesByPost(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city,
@RequestBody Object myCustomObject

){
return "the method is not implemented yet";
}


myCustomObject could have any type of data you defined in your code. Note that in this way, you should send request body as a Json string.






share|improve this answer


























  • you can send body with GET method too, but it's ignored for most cases.

    – Murat Güvenç
    Jan 3 at 11:02











  • @hamid from some other links, I can see, via GET call we can pass RequestBody too. See stackoverflow.com/a/983458/4934937

    – vineeth
    Jan 3 at 11:03













  • @MuratGüvenç This is not a standard way and I suggest to prevent that.

    – hamid ghasemi
    Jan 3 at 11:04






  • 1





    @hamidghasemi Yea... Got it..

    – vineeth
    Jan 3 at 11:18






  • 1





    Some HTTP servers allow it, and some—especially caching proxies—don’t. We tried a POC with Tomcat on which we passed the requestBody successfully. But when we tried the same with Weblogic( which is a caching proxies server), we were not able to succeed.

    – vineeth
    Jan 4 at 4:37














2












2








2







There are two ways for sending parameters in an Http Get method. PathVariable and RequestParam. In this way, sent parameters are visible in the request URL. for example:



www.sampleAddress.com/countries/{parameter1}/get-time?city=someValues


In the above request, parameter1 is a path variable and parameter2 is a request parameter. So an example of a valid URL would be:



www.sampleAddress.com/countries/Germany/get-time?city=berlin


To access these parameters in a java controller, you need to define a specific name for the parameters. For example the following controller will receive this type of requests:



@GetMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCities(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city
){
return "the method is not implemented yet";
}


You are able to send RequestBody through a Get request but it is not recommended according to this link.




yes, you can send a body with GET, and no, it is never useful
to do so.




This elaboration in elasticsearch website is nice too:




The HTTP libraries of certain languages (notably JavaScript) don’t allow GET requests to have a request body. In fact, some users are suprised that GET requests are ever allowed to have a body.



The truth is that RFC 7231—the RFC that deals with HTTP semantics and
content—does not define what should happen to a GET request with a
body! As a result, some HTTP servers allow it, and some—especially
caching proxies—don’t.




If you want to use Post method, you are able to have RequestBody too. In the case you want to send data by a post request, an appropriate controller would be like this:



@PostMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCitiesByPost(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city,
@RequestBody Object myCustomObject

){
return "the method is not implemented yet";
}


myCustomObject could have any type of data you defined in your code. Note that in this way, you should send request body as a Json string.






share|improve this answer















There are two ways for sending parameters in an Http Get method. PathVariable and RequestParam. In this way, sent parameters are visible in the request URL. for example:



www.sampleAddress.com/countries/{parameter1}/get-time?city=someValues


In the above request, parameter1 is a path variable and parameter2 is a request parameter. So an example of a valid URL would be:



www.sampleAddress.com/countries/Germany/get-time?city=berlin


To access these parameters in a java controller, you need to define a specific name for the parameters. For example the following controller will receive this type of requests:



@GetMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCities(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city
){
return "the method is not implemented yet";
}


You are able to send RequestBody through a Get request but it is not recommended according to this link.




yes, you can send a body with GET, and no, it is never useful
to do so.




This elaboration in elasticsearch website is nice too:




The HTTP libraries of certain languages (notably JavaScript) don’t allow GET requests to have a request body. In fact, some users are suprised that GET requests are ever allowed to have a body.



The truth is that RFC 7231—the RFC that deals with HTTP semantics and
content—does not define what should happen to a GET request with a
body! As a result, some HTTP servers allow it, and some—especially
caching proxies—don’t.




If you want to use Post method, you are able to have RequestBody too. In the case you want to send data by a post request, an appropriate controller would be like this:



@PostMapping(value = "/countries/{parameter1}/get-time", produces = "application/json; charset=utf-8")
public String getTimeOfCitiesByPost(
@PathVariable(value = "parameter1") String country,
@RequestParam(value = "city") String city,
@RequestBody Object myCustomObject

){
return "the method is not implemented yet";
}


myCustomObject could have any type of data you defined in your code. Note that in this way, you should send request body as a Json string.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 11:16

























answered Jan 3 at 10:58









hamid ghasemihamid ghasemi

6812725




6812725













  • you can send body with GET method too, but it's ignored for most cases.

    – Murat Güvenç
    Jan 3 at 11:02











  • @hamid from some other links, I can see, via GET call we can pass RequestBody too. See stackoverflow.com/a/983458/4934937

    – vineeth
    Jan 3 at 11:03













  • @MuratGüvenç This is not a standard way and I suggest to prevent that.

    – hamid ghasemi
    Jan 3 at 11:04






  • 1





    @hamidghasemi Yea... Got it..

    – vineeth
    Jan 3 at 11:18






  • 1





    Some HTTP servers allow it, and some—especially caching proxies—don’t. We tried a POC with Tomcat on which we passed the requestBody successfully. But when we tried the same with Weblogic( which is a caching proxies server), we were not able to succeed.

    – vineeth
    Jan 4 at 4:37



















  • you can send body with GET method too, but it's ignored for most cases.

    – Murat Güvenç
    Jan 3 at 11:02











  • @hamid from some other links, I can see, via GET call we can pass RequestBody too. See stackoverflow.com/a/983458/4934937

    – vineeth
    Jan 3 at 11:03













  • @MuratGüvenç This is not a standard way and I suggest to prevent that.

    – hamid ghasemi
    Jan 3 at 11:04






  • 1





    @hamidghasemi Yea... Got it..

    – vineeth
    Jan 3 at 11:18






  • 1





    Some HTTP servers allow it, and some—especially caching proxies—don’t. We tried a POC with Tomcat on which we passed the requestBody successfully. But when we tried the same with Weblogic( which is a caching proxies server), we were not able to succeed.

    – vineeth
    Jan 4 at 4:37

















you can send body with GET method too, but it's ignored for most cases.

– Murat Güvenç
Jan 3 at 11:02





you can send body with GET method too, but it's ignored for most cases.

– Murat Güvenç
Jan 3 at 11:02













@hamid from some other links, I can see, via GET call we can pass RequestBody too. See stackoverflow.com/a/983458/4934937

– vineeth
Jan 3 at 11:03







@hamid from some other links, I can see, via GET call we can pass RequestBody too. See stackoverflow.com/a/983458/4934937

– vineeth
Jan 3 at 11:03















@MuratGüvenç This is not a standard way and I suggest to prevent that.

– hamid ghasemi
Jan 3 at 11:04





@MuratGüvenç This is not a standard way and I suggest to prevent that.

– hamid ghasemi
Jan 3 at 11:04




1




1





@hamidghasemi Yea... Got it..

– vineeth
Jan 3 at 11:18





@hamidghasemi Yea... Got it..

– vineeth
Jan 3 at 11:18




1




1





Some HTTP servers allow it, and some—especially caching proxies—don’t. We tried a POC with Tomcat on which we passed the requestBody successfully. But when we tried the same with Weblogic( which is a caching proxies server), we were not able to succeed.

– vineeth
Jan 4 at 4:37





Some HTTP servers allow it, and some—especially caching proxies—don’t. We tried a POC with Tomcat on which we passed the requestBody successfully. But when we tried the same with Weblogic( which is a caching proxies server), we were not able to succeed.

– vineeth
Jan 4 at 4:37













3















I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?




One thing you are missing is the fact that the semantics of a request body with GET are not well defined.



RFC 7231, Section 4.3.1:




A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.







share|improve this answer
























  • By rejecting request you meant rejecting requestBody right? Because I am able to hit the my controller with the request but the requestBody is empty

    – vineeth
    Jan 3 at 11:09













  • @vineeth to quote from the old c++ standards newsgroup: "not defined" = "could make demons fly out of your nose". So any action the server or framework takes would be seen as ok. Be it rejecting the request, ignoring the body or using the body.

    – jokster
    Jan 3 at 12:57
















3















I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?




One thing you are missing is the fact that the semantics of a request body with GET are not well defined.



RFC 7231, Section 4.3.1:




A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.







share|improve this answer
























  • By rejecting request you meant rejecting requestBody right? Because I am able to hit the my controller with the request but the requestBody is empty

    – vineeth
    Jan 3 at 11:09













  • @vineeth to quote from the old c++ standards newsgroup: "not defined" = "could make demons fly out of your nose". So any action the server or framework takes would be seen as ok. Be it rejecting the request, ignoring the body or using the body.

    – jokster
    Jan 3 at 12:57














3












3








3








I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?




One thing you are missing is the fact that the semantics of a request body with GET are not well defined.



RFC 7231, Section 4.3.1:




A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.







share|improve this answer














I am trying to do a get call with request body(JSON) as the request parameter list exceeds the limit. I am able to send the request via postman/insomnia and request is reaching till controller without any error. But the "requstBody" is empty at controller. What i am missing here?




One thing you are missing is the fact that the semantics of a request body with GET are not well defined.



RFC 7231, Section 4.3.1:




A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.








share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 11:05









VoiceOfUnreasonVoiceOfUnreason

21.8k22251




21.8k22251













  • By rejecting request you meant rejecting requestBody right? Because I am able to hit the my controller with the request but the requestBody is empty

    – vineeth
    Jan 3 at 11:09













  • @vineeth to quote from the old c++ standards newsgroup: "not defined" = "could make demons fly out of your nose". So any action the server or framework takes would be seen as ok. Be it rejecting the request, ignoring the body or using the body.

    – jokster
    Jan 3 at 12:57



















  • By rejecting request you meant rejecting requestBody right? Because I am able to hit the my controller with the request but the requestBody is empty

    – vineeth
    Jan 3 at 11:09













  • @vineeth to quote from the old c++ standards newsgroup: "not defined" = "could make demons fly out of your nose". So any action the server or framework takes would be seen as ok. Be it rejecting the request, ignoring the body or using the body.

    – jokster
    Jan 3 at 12:57

















By rejecting request you meant rejecting requestBody right? Because I am able to hit the my controller with the request but the requestBody is empty

– vineeth
Jan 3 at 11:09







By rejecting request you meant rejecting requestBody right? Because I am able to hit the my controller with the request but the requestBody is empty

– vineeth
Jan 3 at 11:09















@vineeth to quote from the old c++ standards newsgroup: "not defined" = "could make demons fly out of your nose". So any action the server or framework takes would be seen as ok. Be it rejecting the request, ignoring the body or using the body.

– jokster
Jan 3 at 12:57





@vineeth to quote from the old c++ standards newsgroup: "not defined" = "could make demons fly out of your nose". So any action the server or framework takes would be seen as ok. Be it rejecting the request, ignoring the body or using the body.

– jokster
Jan 3 at 12:57











2














put @RequestBody on String requestBody parameter






share|improve this answer
























  • I have tried that. But still same result

    – vineeth
    Jan 3 at 10:39













  • I can actually confirm that this is working with springBoot 2.1.1.RELEASE.

    – maio290
    Jan 3 at 11:07
















2














put @RequestBody on String requestBody parameter






share|improve this answer
























  • I have tried that. But still same result

    – vineeth
    Jan 3 at 10:39













  • I can actually confirm that this is working with springBoot 2.1.1.RELEASE.

    – maio290
    Jan 3 at 11:07














2












2








2







put @RequestBody on String requestBody parameter






share|improve this answer













put @RequestBody on String requestBody parameter







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 10:07









NEGR KITAECNEGR KITAEC

1307




1307













  • I have tried that. But still same result

    – vineeth
    Jan 3 at 10:39













  • I can actually confirm that this is working with springBoot 2.1.1.RELEASE.

    – maio290
    Jan 3 at 11:07



















  • I have tried that. But still same result

    – vineeth
    Jan 3 at 10:39













  • I can actually confirm that this is working with springBoot 2.1.1.RELEASE.

    – maio290
    Jan 3 at 11:07

















I have tried that. But still same result

– vineeth
Jan 3 at 10:39







I have tried that. But still same result

– vineeth
Jan 3 at 10:39















I can actually confirm that this is working with springBoot 2.1.1.RELEASE.

– maio290
Jan 3 at 11:07





I can actually confirm that this is working with springBoot 2.1.1.RELEASE.

– maio290
Jan 3 at 11:07











2














@RequestMapping("/path/{requestBody}")
public Response getResponse(@PathVariable String requestBody) throws IOException { }





share|improve this answer
























  • It would be nice to add some details to this code. Why those annotation ?

    – AxelH
    Jan 3 at 10:16













  • @mkjh my requirement is pass the details in requestBody rather than requestParameter/PathVariable

    – vineeth
    Jan 3 at 10:43











  • @vineeth but requestbody is for POST. You should be using Uri for GET request

    – mkjh
    Jan 3 at 11:02











  • @mkjh See the link provided by maio290 above. GET calls too supports body

    – vineeth
    Jan 3 at 11:05
















2














@RequestMapping("/path/{requestBody}")
public Response getResponse(@PathVariable String requestBody) throws IOException { }





share|improve this answer
























  • It would be nice to add some details to this code. Why those annotation ?

    – AxelH
    Jan 3 at 10:16













  • @mkjh my requirement is pass the details in requestBody rather than requestParameter/PathVariable

    – vineeth
    Jan 3 at 10:43











  • @vineeth but requestbody is for POST. You should be using Uri for GET request

    – mkjh
    Jan 3 at 11:02











  • @mkjh See the link provided by maio290 above. GET calls too supports body

    – vineeth
    Jan 3 at 11:05














2












2








2







@RequestMapping("/path/{requestBody}")
public Response getResponse(@PathVariable String requestBody) throws IOException { }





share|improve this answer













@RequestMapping("/path/{requestBody}")
public Response getResponse(@PathVariable String requestBody) throws IOException { }






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 10:08









mkjhmkjh

1,1751023




1,1751023













  • It would be nice to add some details to this code. Why those annotation ?

    – AxelH
    Jan 3 at 10:16













  • @mkjh my requirement is pass the details in requestBody rather than requestParameter/PathVariable

    – vineeth
    Jan 3 at 10:43











  • @vineeth but requestbody is for POST. You should be using Uri for GET request

    – mkjh
    Jan 3 at 11:02











  • @mkjh See the link provided by maio290 above. GET calls too supports body

    – vineeth
    Jan 3 at 11:05



















  • It would be nice to add some details to this code. Why those annotation ?

    – AxelH
    Jan 3 at 10:16













  • @mkjh my requirement is pass the details in requestBody rather than requestParameter/PathVariable

    – vineeth
    Jan 3 at 10:43











  • @vineeth but requestbody is for POST. You should be using Uri for GET request

    – mkjh
    Jan 3 at 11:02











  • @mkjh See the link provided by maio290 above. GET calls too supports body

    – vineeth
    Jan 3 at 11:05

















It would be nice to add some details to this code. Why those annotation ?

– AxelH
Jan 3 at 10:16







It would be nice to add some details to this code. Why those annotation ?

– AxelH
Jan 3 at 10:16















@mkjh my requirement is pass the details in requestBody rather than requestParameter/PathVariable

– vineeth
Jan 3 at 10:43





@mkjh my requirement is pass the details in requestBody rather than requestParameter/PathVariable

– vineeth
Jan 3 at 10:43













@vineeth but requestbody is for POST. You should be using Uri for GET request

– mkjh
Jan 3 at 11:02





@vineeth but requestbody is for POST. You should be using Uri for GET request

– mkjh
Jan 3 at 11:02













@mkjh See the link provided by maio290 above. GET calls too supports body

– vineeth
Jan 3 at 11:05





@mkjh See the link provided by maio290 above. GET calls too supports body

– vineeth
Jan 3 at 11:05


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020054%2fget-call-with-request-body-request-body-not-accessible-at-controller%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith