本文介绍了使用邮递员客户端使用@RequestParam和@RequestBody调用服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在尝试调用服务

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:

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

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

这篇关于使用邮递员客户端使用@RequestParam和@RequestBody调用服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 10:50