I am getting following error while calling post API.
405 Method Not Allowed
From angular i am calling post API like following.
private createFormUrl = `api/form/add`
public createForm(form: Form): Observable<string> {
return this.httpClient.post<any>(this.createFormUrl, form)
.pipe(catchError(this.handleError));
}
API in JAVA
@RestController
@RequestMapping( value = "/api/form")
public class FormManagementController {
private FormManagementService formmanagementService;
@PostMapping(path = "/add",
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON)
public ResponseEntity<?> createForm(@RequestBody(required = false) Form form) {
String respond = formmanagementService.createForm(form);
return ResponseEntity.status(getProperHttpStatus(respond)).build();
}
Error:
URL: http://localhost/api/form/add (Working in postman)
I checked but, GET is not written any where for this API.
I checked many posts on stackoverflow but, nothing work for me. Any help would be greatly appreciated.