I'm trying to add custom http header to my GET request I'm using Angular 8 and spring boot for my application. I can't get my head around of how to send this header in the right way, and why does the server dosen't get it.. here is my attempt to do so:(client)
const headers = new HttpHeaders().set("realityId", "0");
export class FileService {
constructor(private http: HttpClient) { }
getFileList(): Observable<any> {
return this.http.get(`${this.baseUrl}`,{headers});
}
and the relevant server code from my controller:
public HttpEntity<FlowersList> getFlowersFromFlowers(@RequestHeader String realityId,
@RequestParam("mName") String mName)
no matter what I'm trying to do I keep on getting the error:
[org.springframework.web.bind.MissingRequestHeaderException: Missing request header 'realityId' for
method parameter of type String]
I've been trying to do it like this:
httpOptions = {
headers: new HttpHeaders({ 'realityId': '0' })
};
But nothing, I've been following this tutorial and this one, and trying to get help from this stuck overflow question.
Any help would be appreciate
P.s whatever solutions I find for angular 2 and 4 does not work for me..
edit: I also found this solution , tried the exact same thing, and still keep getting this error..I don't understand what I'm doing wrong