I have the following service in angular 5 application:
const httpOptions = {
headers: new HttpHeaders({
'Accept': 'application/json',
'Content-Type': 'application/json'
})
};
addTrip(trip: Trip): Observable<any> {
console.log('Adding trip ' + JSON.stringify(trip));
return this.http.post(`${this.baseUrl}/Trips/trip/`, JSON.stringify(trip), httpOptions);
}
Trip look like (in angular):
export interface Trip {
description: string;
}
The java code is seam component which use rest api:
@Name("tripFacadeREST")
@Scope(ScopeType.EVENT)
@Path("Trips")
public class TripFacadeREST {
@In private TripDaoHibernateImpl tripDao;
...
@POST
@Path("Trip")
@Consumes("application/json")
public Response addNewTrip(Trip newTrip) {
tripDao.addTrip(newTrip);
return Response.ok().entity("trip added successfully").build();
}
I can't get this call to work, I have tried also put but I understand that put is for update and because the id is created in the server side I've used post, the server side is not triggered. Any idea how to solve this problem? (I was able to use GET annotation in the same service with no issues).