Wondering if anyone knows how to fix Unsupported Encoding "UTF-8" error?
{"fault":{"detail":{"errorcode":"protocol.http.UnsupportedEncoding"},"faultstring":"Unsupported Encoding \"UTF-8\""}}
This error can be seen through trace session within API Management, just before the request is sent to the target server. The resource on the REST service is encoding the response as UTF-8. The last policy to be acted upon, before the error is thrown, is an AssignMessage policy type designating the target server url among other headers set.
Solved! Go to Solution.
Here is a snip of the JAX-RS service provider code:
@GET @Path(value = "one/value") @Produces("application/json") @ApiOperation(value = "Returns a value", response = Object.class, responseContainer = "Response") @ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Internal error"), }) public Response getValue() { JsonObject value=null; try{ value = Json.createObjectBuilder(); } catch (Exception e){ logger.error("Error" , e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Error").build(); } return Response .status(200) .entity(value.toString()) .encoding("UTF-8") .lastModified(new Date()) .build(); }
Solution: Remove UTF-8 encoding from the service provider response.