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).