使用Postman测试REST持久性端点

编程入门 行业动态 更新时间:2024-10-24 12:34:02
本文介绍了使用Postman测试REST持久性端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在尝试构建安全的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持久性端点

本文发布于:2023-10-29 08:17:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539189.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:持久性   测试   Postman   REST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!