Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to fix Unsupported Encoding "UTF-8" error?

Not applicable

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 Solved
0 10 33.3K
1 ACCEPTED SOLUTION

Not applicable

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.

View solution in original post

10 REPLIES 10