415-UnSupported Media Type

2019-08-16 06:40发布

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:

enter image description here

1条回答
叼着烟拽天下
2楼-- · 2019-08-16 06:59

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.

查看更多
登录 后发表回答