3

Azure Maps APIを使用して、座標を使用してポイント周辺の POI を検索しようとしていますが、 Authorizationclient-idを追加して API を呼び出す方法がわかりません。

これは、Microsoft のドキュメント Web サイトで API を試したときに表示されるリクエストのプレビューです。

GET https://atlas.microsoft.com/search/poi/json?api-version=1.0&query=university&lat=10.8232&lon=2.98234&limit=1

Authorization: Bearer eyJ0eXAiOiJKV1……

X-ms-client-id: SUXrtewLVItIG3X5…..
4

2 に答える 2

1

RestSharp を使用できます。認証とクライアント ID がヘッダーとして追加されます。

using RestSharp;

string url = $"https://atlas.microsoft.com/search/poi/json?api-version=1.0&query=university&lat=10.8232&lon=2.98234&limit=1";

var client = new RestClient(url);
var request = new RestRequest(Method.GET);

request.AddHeader("cache-control", "no-cache");
request.AddHeader("Authorization", “Bearer eyJ0eXAiOiJKV1……”);
request.AddHeader("X-ms-client-id", “SUXrtewLVItIG3X5…..”);

IRestResponse response = client.Execute(request);

if (response.IsSuccessful)
{
    string content = response.Content;
}

RestSharp NuGet パッケージをインストールすることから始めることを忘れないでください。

于 2019-03-26T22:40:55.953 に答える