415甚至不支持的媒体类型错误内容类型:邮递员中存在application / json

时间:2018-10-27 11:28:09

标签: json rest jax-rs http-status-code-415

我不熟悉Web服务,因此创建了一个演示Web服务。我正在使用邮递员检查服务,并收到415错误。我的邮递员头中确实有内容类型的application / json。仍然有问题。请帮忙。

 @Path("/orderTracking")
public class OrderRestService {
    @POST
    @Path("/track")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response getOrderStatus(ServiceRequest request) {
ServiceResponse serviceResponse = new ServiceResponse();
        ResponseData responseData = new ResponseData();

        if(request.getRequest().getOrderId() != null) {
            responseData.setOrderId(request.getRequest().getOrderId());
            responseData.setOrderStatus("Order is confirmed");
            responseData.setOrderDate("25/10/2018");
            responseData.setCustomerName("xxx");
            responseData.setCustomerAddress("yyyyyyyyyy");
            responseData.setDeliveryDate("01/11/2018");
        }else {
            responseData.setOrderStatus("Order Failed");
            System.out.println("Error in Service");
        }
        serviceResponse.setResponse(responseData);

        return Response.status(200).entity(serviceResponse).build();

0 个答案:

没有答案