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

时间:2015-06-22 11:55:56

标签: spring postman

试图调用该服务 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 }

回应:

必需的字符串参数&#39; cronExpresssion&#39;不存在

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

1 个答案:

答案 0 :(得分:0)

我担心你想要一点点:RequestParam,RequestBody以及整个REST查询。这三件事中至少有两件是相互排斥的。

我认为你甚至可以通过将被叫URL修改为:

来让Postmaster这样做

http://IP:8080/PQRS/LMN/XYZ/runTest/scheduledautomation/1/XYZ?cronExpression=your-expression

当然这会破坏你的REST界面,但正如我所说:你的处理程序方法有点&#34;过于雄心勃勃&#34;