java - Spring webservice won't read JSON -


It did not seem to bump for more responses as a question editing, I continue to ask in a new thread I am

The thing is that I am trying to establish a very basic web service with Spring, for which I should send JSON via Java.

But I'm very new to Spring, and in general web services, so I do not know where the troubleshooting is from.

Old question:

Now I have this in my controller @RequestMapping (value = "/ toggleB") Send public @ResponseBody string

Send this string to

/ P>

  {"IP": "192.168.1.9"}   

returns a return code of 400.

The thing is, I think there may be some confusion or may disappear in build.gradle (or pom.xml).

My main method is runnable, and looks like this:

  import org.springframework.boot.autoconfigure .EnableAutoConfiguration; Import org.springframework.boot.SpringApplication; Import org.springframework.context.annotation.ComponentScan; @ComponentScan @EnableAutoConfiguration Public class mainFile {public static zero main (string [] args) {SpringApplication.run (mainFile.class, args); }}   

I can not use any beans as a configuration, which may fail in my program?

Thanks for the reply! I hope I do not break the rules by continuing my question like this, but I did not know how to hit the old one. Ahh ... the loss of being completely new on the site, hey.

If you are sending JSON to the requested entity, post it or request a PUT, addition to Jason Add header to accept also. Bring Jason as a string and then use the Jasonn Parser to use it in JasonNeed or whatever you want. And finally a respertainty comes back. Below is a sample code, if necessary, ask specific questions in the comments for clarification.

  @RequestMapping (value = "/ toggle b", method = RequestMethod.POST, header = "accept / application / Jason") Public ResponseEntity & lt; Java.lang.String & gt; SendCommand (@RequestBody String Ident) {// returns your content new responses; String & gt; ("Some feedback data / messages", new HTTP headers (), HTTP Stats.Ok); }    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -