[英]Spring-data-rest testing in POSTMAN
我在Spring-data-rest开发一个应用程序。 我正在测试来自POSTMAN客户端的POST请求以测试是否将数据插入到数据库中。在我的数据库中,我有一个cartItems表。 我可以按如下所示发布JSON时发布数据:merchandise,cart和merchandiseType是外键引用。
{
"rate": 500,
"quantity": 1,
"amount": 500,
"createdAt": "2015-04-12T23:40:00.000+0000",
"updatedAt": "2015-04-14T21:35:20.000+0000",
"merchandise": "http://localhost:8080/sportsrest/merchandises/10",
"cart":"http://localhost:8080/sportsrest/carts/902",
"merchandiseType":"http://localhost:8080/sportsrest/merchandiseTypes/1"
}
但是,当我按以下方式发布数据时,我遇到了错误:我没有放置商品的URL,而是放置了商品JSON,该商品我已经测试了商品表JSON的POST请求:
{
"rate": 500,
"quantity": 1,
"amount": 500,
"createdAt": "2015-04-12T23:40:00.000+0000",
"updatedAt": "2015-04-14T21:35:20.000+0000",
"merchandise": {
"id": 4,
"shortDescription": "white football",
"rate": 500,
"updatedAt": "2015-04-24T18:30:00.000+0000",
"createdAt": "2015-04-20T18:30:00.000+0000",
"longDescription": "test description for binary 1001",
"type": "1"
},
"cart":"http://localhost:8080/sportsrest/carts/902",
"merchandiseType":"http://localhost:8080/sportsrest/merchandiseTypes/1"
}
我收到以下错误消息:
{
"cause": {
"cause": {
"cause": null,
"message": "Template must not be null or empty!"
},
"message": "Template must not be null or empty! (through reference chain: co.vitti.sports.bean.CartItem[\"merchandise\"])"
},
"message": "Could not read JSON: Template must not be null or empty! (through reference chain: co.vitti.sports.bean.CartItem[\"merchandise\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Template must not be null or empty! (through reference chain: co.vitti.sports.bean.CartItem[\"merchandise\"])"
}
有人可以帮我解释为什么我收到此错误。 谢谢。
我猜您没有提供Content-Type:application / json标头。
尝试用“ @RestResource(exported = false)”注释您的“ MerchandiseRepository”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.