我正在使用我组织的Azure数据目录。我不是Catalog的创建者/管理员/所有者,但我可以从Web界面注册/删除目录。rest api未经授权的Azure数据目录
我想为Azure Data Catalog使用rest API。我的等级是否可以? 我遵循了https://msdn.microsoft.com/en-us/library/mt428033.aspx所有步骤,并写了下面的一段代码:
class Program
{
static void Main(string[] args)
{
string url = "https://api.azuredatacatalog.com/catalogs/DefaultCatalog/search/search?searchTerms=My_Server&count=10&startPage=1&api-version=2016-03-30";
HttpWebRequest request = System.Net.WebRequest.Create(url) as System.Net.HttpWebRequest;
Console.WriteLine(AccessToken().CreateAuthorizationHeader());
try
{
WebResponse response = request.GetResponse();
Console.WriteLine(response.ContentLength);
}
catch (Exception e)
{
Console.WriteLine(e);
}
Console.ReadKey();
}
static AuthenticationResult AccessToken()
{
string resourceUri = "https://datacatalog.azure.com";
string clientId = "my-client-id";
string redirectUri = "my-redirect-uri";
string authorityUri = "https://login.windows.net/common/oauth2/authorize";
AuthenticationContext authContext = new AuthenticationContext(authorityUri);
return authContext.AcquireToken(resourceUri, clientId, new Uri(redirectUri), PromptBehavior.RefreshSession);
}
}
,当我尝试从API搜索,我得到以下错误:
System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at HRBIADCAPI.Program.Main(String[] args) in c:\users\naghimir\documents\visual studio 2015\Projects\HRBIADCAPI\HRBIADCAPI\Program.cs:line 32
现在我认为问题在于我没有访问为读/写数据目录而创建的客户端程序(我在Azure Data Factory中做过),但该步骤在文档中也没有。
我是否需要成为所有者,或者是否可以向所有者请求使用Azure Data Catalog API的许可?