Invoking service with @RequestParam and @RequestBody using postman client

3.2k Views Asked by At

Was trying to invoke the service http://IP:8080/PQRS/LMN/XYZ/runTest/scheduledautomation/1/XYZ

with below JSON String


[ {"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 }

Response :

Required String parameter 'cronExpresssion' is not present

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

1

There are 1 best solutions below

0
On BEST ANSWER

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.

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=your-expression

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