Azure Maps Fuzzy Search API (https://atlas.microsoft.com/search/fuzzy/json?) works on Postman but fails on Logic Apps

孤街浪徒 提交于 2021-01-29 08:49:02

问题


I started using the Azure Maps API on a project using Logic Apps (Azure). All of a sudden the HTTP action stopped working and I am getting a 400 BadRequest Error.

"error": { "code": "400 BadRequest", "message": "Bad request: one or more parameters were incorrectly specified or are mutually exclusive."

However, when I call the same API using Postman or my browser, it works fine.

API: https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&subscription-key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&query=2 5 Donlands Ave 4 Toronto Toronto &countrySet=Ca&maxFuzzyLevel=2&limit=1

As I mentioned, this was working and all of a sudden started failing on Logic Apps without making any changes.


回答1:


I exactly have the same issue. I use address rest api to retrieve cities from postal code.

Sample :

https://atlas.microsoft.com/search/address/structured/json?subscription-key=mySubcriptionKey&api-version=1.0&postalcode=35000&countrycode=fr&limit=1

Like you, if I use the query client side, I have a 400 bad request with message : { "error": { "code": "400 BadRequest", "message": "Bad request: one or more parameters were incorrectly specified or are mutually exclusive." } }

Please note that the query is OK for google chrome, but return a 400 bad requests with Brave, Edge (chromium) and Firefox. Note also that the sample web sdk have the same issue and is not updated.

Currently, I don't have any idea about where is the problem.

Edit : After some investigation, i'm pretty sure that it's a Microsoft issue. So, I found a workaround. If I try my query with Firefox, by default I have a 400 and a 200 with chrome. I compare the header and the issue is with the accept-language.

By default, on Chrome, I Have : Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7 On Firefox (Brave, Edge also maybe), I Have : Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3

Please note the inversion between fr-FR and fr. If I change my Accept-Language on Firefox from fr,fr-FR to FR-fr,fr. It's working.

If I set my Accept-Language to "fr" only, I still have a 400. Work with "Fr-fr". So after some test, my conclusion is that atlas have an issue with two letter header accept-langage.

So on my TS/JS code, just add accept-language with 4 letters to work again.

xhr.open('GET', url, true);
xhr.setRequestHeader("Accept-Language", this.acceptLanguage);
xhr.send();

My opinion is that it's a server/ atlas issue, I can't imagine this kind of code evolution from Microsoft ^^



来源:https://stackoverflow.com/questions/61829909/azure-maps-fuzzy-search-api-https-atlas-microsoft-com-search-fuzzy-json-wor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!