0
votes

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
Is there a stack trace in the server logs? - Paul Samsotha
127.0.0.1 - - [29/Nov/2018:14:26:13 +0800] "POST /AdaptiveAuthWSApps/rest/AdaptiveService?uuid=13a1a079-4a39-4625-91a4-ddbf09c2c324&browserinfo=Mozilla%2F8.0%20%28Windows%20NT%206.1%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F49.0.2623.112%20Safari%2F537.36&ipint=16885247&lat=1&longitude=0&sessionid=12w3e4&spid=https%3A%2F%2Fuap&tr=10&jsnum=2&fingerprint=yh8u87&methodset=1%2C1 HTTP/1.1" 404 1078 - user1823924
That's not a stack trace. A stack trace is a list of the method calls leading up to an exception, and the exception with the exception message. Is there an exception thrown on the backend? - Paul Samsotha
No exception thrown at backend. It just display the below msg at Postman: HTTP Status 415 Unsupported Media Type The origin server is refusing to service the request because the payload format is not supported by this method on the target resource. - user1823924

1 Answers

0
votes

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.