简体   繁体   中英

POST method giving errors in Netbeans/ REST

I'm trying to build a POST method in netbeans/ java using REST. For some reason this code keeps returning an error when invoked, any ideas?

@POST
@Path("findByImage")
public String findByImage() {
    return "hello";
}

It returns the error:

Type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.ws.rs.WebApplicationException: java.lang.IllegalArgumentException: Error parsing media type ', application/xml'
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2 logs.

You get this error if you send POST request with wrong 'Content-Type' header (', application/xml'). For example I can reproduce it with next command:

curl -i -X POST -H "Content-Type: , application/xml" http://localhost:8080/jsfDemo/resources/testing/findByImage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM