2
votes

I'm getting Unsupported Media Type while HTTP putting a list. My code as follows:

Client

Client postClient = getClient();
WebResource postWebResource = postClient.resource(DEV_URI+"caches1");
Builder requestBuilder = postWebResource.type(MediaType.APPLICATION_JSON);  
requestBuilder.accept(MediaType.APPLICATION_JSON);
requestBuilder.header("accessor", "1011181517"); 
List<MyEntity> list = new ArrayList<MyEntity>();
MyEntity mapObj = new MyEntity();
mapObj.setId("xxxxxxxxxx");
mapObj.setBookId("xxxxxxxxxxx");
list.add(mapObj);
GenericEntity<List<FacebookEbayMap>> entity = new GenericEntity<List<FacebookEbayMap>>(list) {};
ClientResponse response = requestBuilder.put(ClientResponse.class, entity);

Interface

@PUT
@Path("caches1")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response refreshUserCache1(List<MyEntity> userIdMap,
                                  @Context UriInfo uriInfo,
                                  @Context HttpHeaders httpHeaders);

Resource

public Response refreshUserCache1(List<MyEntity> userIdMap,
    UriInfo uriInfo, HttpHeaders httpHeaders) {
        return Response.ok("", MediaType.APPLICATION_JSON).build();
    }

I tried with and without GenericType at both client and server side. Could someone please help here?

Exception

The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Unsupported Media Type).

2
Can you please edit your post and format your code with the « Code Sample » tool?yves amsellem

2 Answers

1
votes

Update the jar files properly. For example, if there are 3 applications named A, B and C then you are exporting a jar file in application A and you are importing that in the remaining applications B and C means, then you have to update the jar files properly, whenever you are changing the classes which belong to the jar file.

1
votes

Make sure you have mimepull.jar in you lib/the classpath.