0

In my application, I'm using angular 8 client to get data from my spring boot server, here is the get requesr from the server:

 @RequestMapping(value = "/Flowers", method = RequestMethod.GET)
 public HttpEntity<FlowersList> getFlowersFromFlowers(@RequestHeader String realityId, 
 @RequestParam("mName") String mName)

And my relecent client code:

httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
params: new HttpParams().set('realityId', '0')
};

constructor(private http: HttpClient) { }

getFileList(): Observable<any> {
return this.http.get(`${this.baseUrl}`,this.httpOptions);
}

I keep on getting the following error from the server:

[org.springframework.web.bind.MissingRequestHeaderException: Missing request header 'realityId' for 
method parameter of type String]

I was trying to follow this stuck overflow question and this tutorial but didn't get any luck. I want to pass in my request header the value '0'(string) for the server's 'realityId' field. Any help would be appreciated, been stuck on this one for quite awhile

edit: been trying to do it like this:

 httpOptions = {
headers: new HttpHeaders({ 'realityId': '0' })
};

still nothing..

Tali
  • 77
  • 2
  • 11
  • Does this answer your question? [How to correctly set Http Request Header in Angular 2](https://stackoverflow.com/questions/41133705/how-to-correctly-set-http-request-header-in-angular-2) – Rich Apr 30 '20 at 20:47
  • @Rick thank you for your answer, I forgot to mention, I'm using angular 8 – Tali Apr 30 '20 at 20:50

0 Answers0