Angular HttpClient issue when calling Bing Maps Locations REST methods

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Angular HttpClient issue when calling Bing Maps Locations REST methods



I have an existing call to Bing Maps made with Angular 4 Http service, that is working correctly:


this.http.get(".../Locations?...&key=mykey")



I'm trying to change the call to use the HttpClient service introduced in Angular 4.3, but when trying the same code:


this.httpClient.get(".../Locations?...&key=mykey")



then the request is sent with the preflight OPTIONS request, and bing maps obviously refuses it.



I've tried to observe the request instead of the body, requesting a text response, and force the Accept header to text, but had no success.



Headers of the Http request (working):


Accept: application/json, text/plain, */*
Origin: http://localhost:4200
Referer: http://localhost:4200/
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36



Headers of the HttpClient request (not working):


Access-Control-Request-Headers: authorization
Access-Control-Request-Method: GET
Origin: http://localhost:4200
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36



Any idea about why the HttpClient request is so different than the Http request?how do I force the HttpClient to skip the preflight OPTIONS request? Am I missing something?



Thanks in advance for any help





Are your URLs relative or absolute? because I only see ".../Locations ..., not knowing what the first three dots stand for! And by the way, do you have an CORS plugin or something similar activated?
– imans77
1 min ago




".../Locations ...









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived