Currently facing a problem where the request to Azure Search API is returning an "Unknown error".
I got the .Get() request working in postman and thought it would be theoretically the same set-up in Angular using the Http Client.
export class AzureSearchConfigComponent implements OnInit {
synonyms: any[];
private synonymUrl = 'https://name.search.windows.net/synonymmaps?api-version=2017-11-11'
constructor(private http: HttpClient) { }
ngOnInit()
{
let headers = new HttpHeaders();
headers = headers
.set('Content-Type', 'application/json')
.set('api-key','xxxx-xxx-xxxxx');
this.http.get(this.synonymUrl,{headers:headers})
.subscribe(
repsonse => {
console.log(repsonse);
}
);
}
}
Error message:
ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …}
Postman Response:
also getting the error:
Response for preflight is invalid (redirect)
