我一直在尝试构建安全的REST端点来保存(并返回)人员对象。到目前为止,我有如下方法:
I have been trying to build a secured REST endpoint to save (and return) a person object. So far I have a method as below:
@RequestMapping(value = "/save/", method = RequestMethod.POST) public Person save(@RequestBody Person person) { return repository.save(person); }我一直在尝试使用Postman测试此终结点,但是不要似乎能够以正确的方式构造URL。我应该说我已经成功测试了find(Long id)(/ find / {id})和findall。
I have been trying to use Postman to test this endpoint, but don't seem to be able to structure the URL in the correct way. I should say that I have successfully tested find(Long id) (/find/{id}) and findall.
localhost:8080/api/save?person={"id":2,"first":"Brian","last":"Smith"}首先,这是构造用于保存对象的端点的正确方法吗,并且Postman结构是否正确?
First, is this the correct way to structure an endpoint for saving an object, and is the Postman structure correct?
推荐答案您的方法是POST。因此,您应该像这样传递您的有效负载。
Your method is POST. So you should pass on your payload like this.
还请确保您已提及您的网站应用程序上下文根。如果api是您的上下文根,那么您是正确的。但是,如果是这种情况,则将其更改为一些有意义的名称。
Also make sure that you have mentioned your web application context root. If api is your context root, then you are correct. But if it is the case then change it to some meaningful name.
更多推荐
使用Postman测试REST持久性端点
发布评论