@Override public PartialRestResponse buildResponse( final RestRequest request, final RoutingResult routingResult, final Object object, final Map<String, String> headers) throws IOException { @SuppressWarnings({"unchecked"}) /** constrained by the signature of {@link CollectionResource#batchCreate} */ BatchCreateResult<?, ?> list = (BatchCreateResult<?, ?>) object; CollectionResponse<CreateStatus> batchResponse = new CollectionResponse<CreateStatus>(CreateStatus.class); for (CreateResponse e : list.getResults()) { CreateStatus s = new CreateStatus(); if (e.hasId()) { s.setId(e.getId().toString()); } s.setStatus(e.getStatus().getCode()); batchResponse.getElements().add(s); } headers.put(RestConstants.HEADER_LINKEDIN_TYPE, CollectionResponse.class.getName()); headers.put(RestConstants.HEADER_LINKEDIN_SUB_TYPE, CreateStatus.class.getName()); return new PartialRestResponse(batchResponse); }