Category : spring-rest

Spring REST API is responding with following response: On successful execution : It returns me a response of Text type. On unsuccessful execution : It returns me JSON error object. Front-End Service Class : private detailsURL = ‘http://localhost:8080/register’; constructor(private http:HttpClient){} register(regisDetails): Observable<any>{ return this.http.post(this.detailsURL,regisDetails); } Front-End Component Class: registerUser(){ this.service.register(this.regisForm.value).subscribe( success => this.successMessage = success, ..

Read more

I thought I’d allowed access to all origins but I’m still getting this error. Access to XMLHttpRequest at ‘localhost:8080/login’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https. My Rest Controller: package com.gms.GroceryManagementSystem.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import ..

Read more

When I’m running in my local machine it’s working fine, after deploying into dev server I’m encountering the below issue file upload failed, Reason: 417 (Expectation Failed) The files are uploading into the project directory of path src/main/webapp/upload-dir angular service class upload(application: JobApplication): Observable<HttpEvent<any>> { var formData = new FormData(); ( application.prevFile ) && formData.append( ..

Read more

I am facing some problem sending response back to client. Java Code @POST @Path(“/previewEmail”) @Consumes(MediaType.APPLICATION_JSON) Public ResponseEntity<JsonNode> previewEmail(String requestBody) { return new ResponseEntity<JsonNode>(HttpStatus.BAD_REQUEST); } AngularJs Code $http.post(‘/previewEmail’, requestBody).then(function (response) { if (response.status == 200) { console.log(“Success”); } }, function (error) { console.log(“Error”); }); When I am hitting this api, I am getting following response object: ..

Read more

I have problems with adding to database by using Spring Data, Rest endpoint and AngularJS. Normally everything is working just fine, everything is adding corectly, but when I added a reletion ManyToOne to Ingredients entity I don’t know how to put it to database with that relation. Ingredients Entity: @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name=”ingredients_id”) private ..

Read more