I have method like this:
@PostMapping(path = "/workflow-services/{service_id}/tickets",
consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<TicketIdResponse> createTicket(@PathVariable("service_id") String serviceId,
@RequestBody @Validated CreateTicketRequest request, @RequestAttribute Payload payload) {
log.info("Start create ticket [{}]", request);
TicketIdResponse response = ticketService.createTicket(serviceId, request, payload);
log.info("Create ticket response: {}", response);
return ResponseFactory.success(response);
}
so how to set value to @RequestAttribute Payload in postman or feign client
Thank you very much!
The @RequestAttribute annotation is usually used to retrieve data that is populated on the server-side but during the same HTTP request. For example, if you have used an interceptor, filter or possibly an aspect to populate the "payload" attribute then you should be able to access this using the @RequestAttribute annotation.
If you are looking to pass something from an external client (ie via postman, curl or any other simple client) - @RequestAttribute is not the way forward.
Good references; https://www.baeldung.com/whats-new-in-spring-4-3 https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/request-attribute.html
This SO post may also help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.