Restful web service 415












0














@RestController
@RequestMapping(value="/uri",produces = "application/json",
consumes="application/json")
public class VisitorService {
VisitorDAO vis=new VisitorDAO();

@RequestMapping(value = "/ex" ,method = RequestMethod.POST)
public String showDetails(@RequestBody VisitorDTO visitor){
vis.addVisitorEntry(visitor);
return "success"+visitor;
}}


Above is my rest service.
whenever I hit a post using the URL with the below JSON,



  {
"phoneNumber" : 188892,
"name" : "kikiki" ,
"email" : "loa@gmail.com",
"purpose" : "Business",
"hostName" : "sjs S Murthy"
}


im getting HTTP Status 415 – Unsupported Media Type.
why would that be?










share|improve this question









New contributor




Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • May be you are missing Accept: application/json in the HTTP request?
    – Ken Chan
    20 hours ago












  • how you are calling the rest service, I mean r u using postman?? check your content type there
    – Rezwan
    20 hours ago










  • nope, sending request through postman, have sent the request ussing application/json header.
    – Kiran S
    20 hours ago










  • yes , added content type- appplication/json
    – Kiran S
    20 hours ago
















0














@RestController
@RequestMapping(value="/uri",produces = "application/json",
consumes="application/json")
public class VisitorService {
VisitorDAO vis=new VisitorDAO();

@RequestMapping(value = "/ex" ,method = RequestMethod.POST)
public String showDetails(@RequestBody VisitorDTO visitor){
vis.addVisitorEntry(visitor);
return "success"+visitor;
}}


Above is my rest service.
whenever I hit a post using the URL with the below JSON,



  {
"phoneNumber" : 188892,
"name" : "kikiki" ,
"email" : "loa@gmail.com",
"purpose" : "Business",
"hostName" : "sjs S Murthy"
}


im getting HTTP Status 415 – Unsupported Media Type.
why would that be?










share|improve this question









New contributor




Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • May be you are missing Accept: application/json in the HTTP request?
    – Ken Chan
    20 hours ago












  • how you are calling the rest service, I mean r u using postman?? check your content type there
    – Rezwan
    20 hours ago










  • nope, sending request through postman, have sent the request ussing application/json header.
    – Kiran S
    20 hours ago










  • yes , added content type- appplication/json
    – Kiran S
    20 hours ago














0












0








0







@RestController
@RequestMapping(value="/uri",produces = "application/json",
consumes="application/json")
public class VisitorService {
VisitorDAO vis=new VisitorDAO();

@RequestMapping(value = "/ex" ,method = RequestMethod.POST)
public String showDetails(@RequestBody VisitorDTO visitor){
vis.addVisitorEntry(visitor);
return "success"+visitor;
}}


Above is my rest service.
whenever I hit a post using the URL with the below JSON,



  {
"phoneNumber" : 188892,
"name" : "kikiki" ,
"email" : "loa@gmail.com",
"purpose" : "Business",
"hostName" : "sjs S Murthy"
}


im getting HTTP Status 415 – Unsupported Media Type.
why would that be?










share|improve this question









New contributor




Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











@RestController
@RequestMapping(value="/uri",produces = "application/json",
consumes="application/json")
public class VisitorService {
VisitorDAO vis=new VisitorDAO();

@RequestMapping(value = "/ex" ,method = RequestMethod.POST)
public String showDetails(@RequestBody VisitorDTO visitor){
vis.addVisitorEntry(visitor);
return "success"+visitor;
}}


Above is my rest service.
whenever I hit a post using the URL with the below JSON,



  {
"phoneNumber" : 188892,
"name" : "kikiki" ,
"email" : "loa@gmail.com",
"purpose" : "Business",
"hostName" : "sjs S Murthy"
}


im getting HTTP Status 415 – Unsupported Media Type.
why would that be?







java json spring rest http-status-code-415






share|improve this question









New contributor




Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 19 hours ago





















New contributor




Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 20 hours ago









Kiran S

33




33




New contributor




Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Kiran S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • May be you are missing Accept: application/json in the HTTP request?
    – Ken Chan
    20 hours ago












  • how you are calling the rest service, I mean r u using postman?? check your content type there
    – Rezwan
    20 hours ago










  • nope, sending request through postman, have sent the request ussing application/json header.
    – Kiran S
    20 hours ago










  • yes , added content type- appplication/json
    – Kiran S
    20 hours ago


















  • May be you are missing Accept: application/json in the HTTP request?
    – Ken Chan
    20 hours ago












  • how you are calling the rest service, I mean r u using postman?? check your content type there
    – Rezwan
    20 hours ago










  • nope, sending request through postman, have sent the request ussing application/json header.
    – Kiran S
    20 hours ago










  • yes , added content type- appplication/json
    – Kiran S
    20 hours ago
















May be you are missing Accept: application/json in the HTTP request?
– Ken Chan
20 hours ago






May be you are missing Accept: application/json in the HTTP request?
– Ken Chan
20 hours ago














how you are calling the rest service, I mean r u using postman?? check your content type there
– Rezwan
20 hours ago




how you are calling the rest service, I mean r u using postman?? check your content type there
– Rezwan
20 hours ago












nope, sending request through postman, have sent the request ussing application/json header.
– Kiran S
20 hours ago




nope, sending request through postman, have sent the request ussing application/json header.
– Kiran S
20 hours ago












yes , added content type- appplication/json
– Kiran S
20 hours ago




yes , added content type- appplication/json
– Kiran S
20 hours ago












1 Answer
1






active

oldest

votes


















0














Check that you have set the @EnableWebMvc annotation in a @Configuration class.



Also, try adding the following dependencies to your pom.xml (if not using Maven, just add them to your classpath however you prefer).



<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>


Spring uses Jackson and Jackson-databind to parse the request's JSON body into a Java Object.






share|improve this answer








New contributor




gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • have used xml based configuration
    – Kiran S
    19 hours ago










  • Try adding this to your xml config: <mvc:annotation-driven />, and you still need the Jackson libraries in your classpath.
    – gbandres
    19 hours ago












  • thanks mate , it worked!
    – Kiran S
    19 hours ago











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
});


}
});






Kiran S is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53942991%2frestful-web-service-415%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Check that you have set the @EnableWebMvc annotation in a @Configuration class.



Also, try adding the following dependencies to your pom.xml (if not using Maven, just add them to your classpath however you prefer).



<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>


Spring uses Jackson and Jackson-databind to parse the request's JSON body into a Java Object.






share|improve this answer








New contributor




gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • have used xml based configuration
    – Kiran S
    19 hours ago










  • Try adding this to your xml config: <mvc:annotation-driven />, and you still need the Jackson libraries in your classpath.
    – gbandres
    19 hours ago












  • thanks mate , it worked!
    – Kiran S
    19 hours ago
















0














Check that you have set the @EnableWebMvc annotation in a @Configuration class.



Also, try adding the following dependencies to your pom.xml (if not using Maven, just add them to your classpath however you prefer).



<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>


Spring uses Jackson and Jackson-databind to parse the request's JSON body into a Java Object.






share|improve this answer








New contributor




gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • have used xml based configuration
    – Kiran S
    19 hours ago










  • Try adding this to your xml config: <mvc:annotation-driven />, and you still need the Jackson libraries in your classpath.
    – gbandres
    19 hours ago












  • thanks mate , it worked!
    – Kiran S
    19 hours ago














0












0








0






Check that you have set the @EnableWebMvc annotation in a @Configuration class.



Also, try adding the following dependencies to your pom.xml (if not using Maven, just add them to your classpath however you prefer).



<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>


Spring uses Jackson and Jackson-databind to parse the request's JSON body into a Java Object.






share|improve this answer








New contributor




gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









Check that you have set the @EnableWebMvc annotation in a @Configuration class.



Also, try adding the following dependencies to your pom.xml (if not using Maven, just add them to your classpath however you prefer).



<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version> // 2.4.3
</dependency>


Spring uses Jackson and Jackson-databind to parse the request's JSON body into a Java Object.







share|improve this answer








New contributor




gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 19 hours ago









gbandres

825




825




New contributor




gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






gbandres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • have used xml based configuration
    – Kiran S
    19 hours ago










  • Try adding this to your xml config: <mvc:annotation-driven />, and you still need the Jackson libraries in your classpath.
    – gbandres
    19 hours ago












  • thanks mate , it worked!
    – Kiran S
    19 hours ago


















  • have used xml based configuration
    – Kiran S
    19 hours ago










  • Try adding this to your xml config: <mvc:annotation-driven />, and you still need the Jackson libraries in your classpath.
    – gbandres
    19 hours ago












  • thanks mate , it worked!
    – Kiran S
    19 hours ago
















have used xml based configuration
– Kiran S
19 hours ago




have used xml based configuration
– Kiran S
19 hours ago












Try adding this to your xml config: <mvc:annotation-driven />, and you still need the Jackson libraries in your classpath.
– gbandres
19 hours ago






Try adding this to your xml config: <mvc:annotation-driven />, and you still need the Jackson libraries in your classpath.
– gbandres
19 hours ago














thanks mate , it worked!
– Kiran S
19 hours ago




thanks mate , it worked!
– Kiran S
19 hours ago










Kiran S is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Kiran S is a new contributor. Be nice, and check out our Code of Conduct.













Kiran S is a new contributor. Be nice, and check out our Code of Conduct.












Kiran S is a new contributor. Be nice, and check out our Code of Conduct.
















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f53942991%2frestful-web-service-415%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

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas