使用邮递员客户端使用@RequestParam和@RequestBody调用服务

编程入门 行业动态 更新时间:2024-10-27 02:28:32
本文介绍了使用邮递员客户端使用@RequestParam和@RequestBody调用服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

正在尝试调用服务 http:// IP:8080 / PQRS / LMN / XYZ / runTest / scheduledautomation / 1 / XYZ

JSON字符串以下

[ {"paramName":"TEST_TARGET_IDENTIFIER","paramValue":"ETest"},{"paramName":"TEST_SOURCE_ENTRY_IDENTIFIER","paramValue":"com.pack.etest"}]

@ResponseStatus(value = HttpStatus.NO_CONTENT) @RequestMapping(value = "/runTest/scheduledautomation/{runId}/{testEngine}", method = RequestMethod.POST) public void runScheduledAutomatedTest(@RequestParam String cronExpresssion, @RequestParam(required = false) @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime endTime, @PathVariable Integer runId, @PathVariable TestEngine testEngine, @RequestBody List<TestEngineParam> testEngineParams) throws Exception { //Some Code }

响应:

必需的字符串参数'cronExpresssion'不存在

Required String parameter 'cronExpresssion' is not present

如何在邮递员客户端上调用混合的 @RequestParam 和 @RequestBody 服务?

how to invoke mixed @RequestParam and @RequestBody services on postman client ?

推荐答案

我担心您想要的太多了:RequestParam,RequestBody以及作为REST查询的所有内容。这三件事中至少有两个是互斥的。

I fear you want a little bit too much: RequestParam, RequestBody AND the whole thing as a REST query. At least two of the three things are mutually exclusive.

我想您甚至可以通过将调用的URL修改为:

I think you could even get Postmaster to do this by modifying the called URL to:

http:// IP:8080 / PQRS / LMN / XYZ / runTest / scheduledautomation / 1 / XYZ?cronExpression =您的表达式

当然,这会破坏您的REST接口,但是正如我说:您的处理程序方法有点过于雄心勃勃 。

Of course this would ruin your REST interface, but as I said: your handler method is a little bit "over-ambitious".

更多推荐

使用邮递员客户端使用@RequestParam和@RequestBody调用服务

本文发布于:2023-10-29 13:20:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539801.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:邮递员   客户端   RequestBody   RequestParam

发布评论

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

>www.elefans.com

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