问题描述
我开始在使用Logic Apps(Azure)的项目上使用Azure Maps API.突然,HTTP动作停止了,我收到了400 BadRequest错误.
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.
错误":{"code":"400 BadRequest","message":错误的请求:一个或多个参数指定错误或相互排斥."
"error": { "code": "400 BadRequest", "message": "Bad request: one or more parameters were incorrectly specified or are mutually exclusive."
但是,当我使用Postman或浏览器调用相同的API时,它可以正常工作.
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多伦多& countrySet = Ca& maxFuzzyLevel =2& limit = 1
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
正如我提到的那样,这是可行的,并且突然在没有进行任何更改的情况下开始在Logic Apps上失败.
As I mentioned, this was working and all of a sudden started failing on Logic Apps without making any changes.
推荐答案
我确实有相同的问题.我使用address rest api从邮政编码中检索城市.
I exactly have the same issue.I use address rest api to retrieve cities from postal code.
样品:
与您一样,如果我使用查询客户端,则会收到400错误的请求,并显示以下消息:{错误": {"code":"400 BadRequest","message":错误的请求:错误地指定了一个或多个参数或它们是互斥的."}}
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." }}
请注意,对于谷歌浏览器来说,查询是可以的,但对于Brave,Edge(铬)和Firefox,则会返回400个错误的请求.还要注意,示例Web SDK具有相同的问题,并且不会更新.
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.
经过一些调查,我很确定这是微软的问题.因此,我找到了解决方法.如果我尝试使用Firefox查询,则默认情况下,我有一个400和一个带有chrome的200.我比较了标头,问题出在接受语言上.
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.
默认情况下,在Chrome上,我有:接受语言:fr-FR,fr; q = 0.9,en-US; q = 0.8,en; q = 0.7在Firefox上(可能还包括勇敢者,Edge),我有:接受语言:fr,fr-FR; q = 0.8,en-US; q = 0.5,en; q = 0.3
By default, on Chrome, I Have : Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7On Firefox (Brave, Edge also maybe), I Have : Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
请注意fr-FR和fr之间的反转.如果我在Firefox上将我的接受语言从fr,fr-FR更改为FR-fr,fr.它正在工作.
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.
如果仅将我的Accept-Language(接受语言)设置为"fr",那么我仍然有400.使用"Fr-fr".因此,经过一些测试,我的结论是图集存在两个字母标题的accept-langage问题.
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.
因此,在我的TS/JS代码上,只需添加带有4个字母的accept-language即可重新工作.
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();
我的看法是这是服务器/地图集的问题,我无法想象这种来自Microsoft的代码演变^^
My opinion is that it's a server/ atlas issue, I can't imagine this kind of code evolution from Microsoft ^^
这篇关于Azure Maps模糊搜索API(https://atlas.microsoft.com/search/fuzzy/json?)在Postman上有效,但在Logic Apps上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!