0
我在调用放置资源时出现400错误:“code”:400,“message”:“无法处理JSON”。我正在使用嵌入式码头服务器Dropwizard 8.0.1 PUT返回400
我使用邮递员作为客户端进行测试。
这里是在put方法的资源的方法:
@Path("/Ads")
public class AdResource {
@PUT
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Timed
@UnitOfWork
public Response update(@Valid AdDTO adDto) {
Ad ad = adDto.buildAd();
ad = adDao.merge(ad);
return Response.ok(toJson(ad)).build();
}
}
下面是从客户端发送的JSON数据:
{
"id": 44,
"created": 1430927007000,
"updated": 1430927052000,
"category": "Voiture",
"type": "Berline",
"make": "AUDI",
"model": "A3",
"month": null,
"year": 2002,
"trimVersion": null,
"transmission": "Manuelle",
"fuel": "Diesel",
"door": "4 portes",
"color": "#FC809B",
"metal": true,
"warranty": true,
"publish": false,
"price": 123,
"mileage": 123,
"power": 123,
"description": "<p>df sdfds sdfsdf sdfsdfds sdfsdfsd</p>",
"adImages": [
{
"id": 55,
"created": 1430926983000,
"updated": 1430926983000,
"name": "amine.png",
"url": "http://localhost/assets/photo/55/photo.png",
"photoUrl": "http://localhost/assets/ad/44/55.jpg",
"thumbPhotoUrl": "http://localhost/assets/ad/44/55_thumb.jpg"
},
{
"id": 54,
"created": 1430926982000,
"updated": 1430926982000,
"name": "amine2.jpg",
"url": "http://localhost/assets/photo/54/photo.jpg",
"photoUrl": "http://localhost/assets/ad/44/54.jpg",
"thumbPhotoUrl": "http://localhost/assets/ad/44/54_thumb.jpg"
}
],
"options": [
"1",
"2",
"13",
"3",
"14",
"15"
]
}
桩和get方法工作得很好。 我使用dropwizard 8.0.1 java 8.
运行什么服务器?你如何发送请求?您需要为您的问题添加更多信息。 – JoeG
刚刚添加更多信息 –
@MasterMind能否检查并从服务器上的日志中发布错误堆栈跟踪?看起来像你的应用程序试图解析JSON到你的'AdDTO'中,但由于某种原因它失败了。 –