Reputation: 43
I have a Java program that uses Postman. I am trying to make a post request on Postman. My code:
@RestController()
@RequestMapping("/v1/e")
public class EC {
@PostMapping(path = "{document}", consumes = "application/json", produces = "application/json")
public ResponseEntity<InputStreamResource> createDocument(@PathVariable Dtype document,@RequestBody String data){
//code
}
Below is the URL I am using to post:
http://localhost:8080/v1/e?document=E_PC
However, I am getting the following error:
{
"timestamp": "2020-08-05T02:22:03.008+0000",
"status": 404,
"error": "Not Found",
"message": "Not Found",
"path": "/v1/e"
}
Upvotes: 1
Views: 13589
Reputation: 1
This would work fine:
@RestController()
@RequestMapping("/v1/e/{document}")
public class EC {
@PostMapping
public ResponseEntity<InputStreamResource> createDocument(@PathVariable Dtype document,@RequestBody String data) {
//code
}
Upvotes: 0
Reputation: 659
You can also use like below:
@RestController
@RequestMapping("/v1/e")
public class EC {
@PostMapping
public ResponseEntity<?> createDocument(@RequestParam("document") String document){
//code
}
}
And your POST REQUEST
is http://localhost:8080/v1/e?document=E_PC
Upvotes: 0