415-UnSupported Media Type

2019-08-16 06:24发布

问题:

While performing testing RESTFUL Web Service using POSTMAN, I encountered the below error :

415 UnSupported Media Type

Currently in my code, I'm using MediaType.TEXT_PLAIN. This is due to one of the answer from page enter link description here telling that if you need to return integer, you need to use TEXT_PLAIN.

May I know is the data that I provide in the web service is compatible with TEXT_PLAIN or not.

@POST
@Path("/post")
@Produces(MediaType.TEXT_PLAIN)

public int adaptiveAuth( @FormDataParam("uuid") String uuID, 
        @FormDataParam("browserinfo") String browserInfo, 
        @FormDataParam("ipint") long ipInt, 
        @FormDataParam("lat") double latiTude, 
        @FormDataParam("longitude") double longiTude, 
        @FormDataParam("sessionid") String sessionID, 
        @FormDataParam("spid") String spID, 
        @FormDataParam("tr") int tR, 
        @FormDataParam("jsnum") int jsNum, 
        @FormDataParam("fingerprint") String fingerPrint, 
        @FormDataParam("methodset") MethodClass[][] methodSet) throws SQLException{ 

The way I tested in Postman are describe as below:

回答1:

Solution. 1. Remove header value in SOAP UI. 2. I was unable to process an array in Jersey. Instead of process MethodClass [][] methodSet, I'm sending the value one by one. 3. I also change back from MediaType.MULTIPART_FORM_DATA to MediaType.PLAIN_TEXT

My code is working now.

Thanks for the help.