網域的作業 (預覽) | Graph API 參考
**適用於︰**Graph API | Azure Active Directory
本主題討論如何使用 Azure Active Directory (AD) Graph API 對網域執行作業。
重要
網域作業目前處於預覽狀態,而且只有 Azure AD Graph API 測試版才予以支援。
Graph API 是 OData 3.0 相容的 REST API,可讓您以程式設計方式存取 Azure Active Directory 中的目錄物件,例如使用者、群組、組織連絡人和應用程式。
重要
您也可以透過 Microsoft Graph 取得 Azure AD Graph API 功能,這個統一 API 同時也包含如 Outlook、OneDrive、OneNote、Planner 和 Office Graph 等其他 Microsoft 服務 API,讓您可以使用單一的存取權杖透過單一端點存取所有 API。 請注意,Microsoft Graph 目前不支援網域作業,您必須使用 Azure AD Graph API 來取得這項功能。
執行網域的 REST 作業
為了使用 Graph API 執行網域的作業,請使用支援的方法 (GET、POST、PATCH、PUT 或 DELETE) 將 HTTP 要求傳送到端點,而端點的目標設為網域資源集合、特定網域、網域的導覽屬性,或是可對網域呼叫的函數或動作。
Graph API 要求使用下列基本 URL:
https://graph.windows.net/{tenant_id}/{resource_path}?{api_version}[odata_query_parameters]
重要
傳送到 Graph API 之要求的格式必須正確、目標設為有效的端點和Graph API 版本,而且其 Authorization
標頭中攜帶取自 Azure AD 的有效存取權杖。 如需使用 Graph API 建立要求以及接收回應的詳細資訊,請參閱[Operations Overview]。
您可以根據目標設為租用戶中的所有網域集合、個別網域還是特定網域的導覽屬性,透過不同的方式指定 {resource_path}
。
/domains
將目標設為網域資源集合。 您可以使用此資源路徑讀取租用戶中的所有網域或篩選過的網域清單,或在租用戶中建立一或多個新的網域。/domains({domain_name})
將目標設為租用戶中的個別網域。 您可以將domain-name
指定為以單引號括住之目標網域的完整網域名稱。 您可以使用此資源路徑取得網域的已宣告屬性、修改網域的已宣告屬性或刪除網域。/domains({domain_name})/{nav_property}
將目標設為網域的指定導覽屬性。 您可以使用它來傳回所指定網域的目標導覽屬性所參考的一或多個物件。 注意:這種形式的定址僅供讀取。/domains({domain_name})/$links/{nav_property}
將目標設為網域的指定導覽屬性。 您可以使用這種定址形式來讀取和修改導覽屬性。 讀取時,此屬性所參考的物件會傳回為回應主體中的一或多個連結。 寫入時,物件會指定為要求主體中的一或多個連結。
例如,下列要求會傳回所指定網域之服務設定記錄的連結︰
GET https://graph.windows.net/myorganization/domains('contoso.com')/serviceConfigurationRecords?api-version=beta
重要︰只有測試版才支援網域的作業。
網域的基本作業 (預覽)
您可以將目標設為網域資源集合或特定網域,來執行網域的基本建立、讀取、更新和刪除 (CRUD) 作業以及其已宣告屬性。 下列各主題示範做法。
Graph API 支援群組的作業,如下所示︰
- 建立 (POST):未驗證和已驗證網域。
- 讀取 (GET):所有網域。
- 更新 (PATCH):僅已驗證網域。 並未支援所有屬性。
- 刪除 (DELETE):所有網域。
取得網域 (預覽)
取得網域集合。 您可以將 OData 查詢參數加入對回應進行篩選、排序和分頁的要求中。 如需詳細資訊,請參閱 Azure AD Graph API 中支援的查詢、篩選和分頁選項。
成功時,傳回 [Domain] 物件集合;否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。
{
"api": "Domains",
"operation": "get domains",
"showComponents": {
"codeGenerator": "true",
"tryFeature": "false"
}
}
取得網域 (預覽)
取得指定的網域。 指定具有完整網域名稱的網域。
成功時,傳回所指定網域的 [Domain] 物件;否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。
{
"api": "Domains",
"operation": "get a domain",
"showComponents": {
"codeGenerator": "true",
"tryFeature": "false"
}
}
建立網域 (預覽)
將網域新增至租用戶。 要求主體包含新網域的 name 屬性。 這是唯一可指定且為必要的屬性。
下表顯示建立網域時所需的屬性。
必要參數 | 類型 | 說明 |
---|---|---|
名稱 | 字串 | 新網域的完整網域名稱;例如,"contoso.com"。 |
重要︰如果正在建立的網域是租用戶中現有已驗證網域的子網域,則會將它建立為已驗證網域 (isVerified 屬性是 true);否則,會將它建立為未驗證網域 (isVerified 屬性是 false)。
成功時,傳回新建立的 [Domain];否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。
{
"api": "Domains",
"operation": "create domain"
}
更新網域 (預覽)
更新網域的屬性。 在要求主體中指定任何可寫入的 [Domain] 屬性。 只會變更您所指定的屬性。
重要︰只能更新已驗證網域。
成功時,不會傳回回應主體;否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。
{
"api": "Domains",
"operation": "update domain"
}
刪除網域 (預覽)
刪除網域。 刪除的網域無法復原。
成功時,不會傳回回應主體;否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。
{
"api": "Domains",
"operation": "delete domain"
}
網域導覽屬性的作業 (預覽)
網域與目錄中其他物件 (例如其驗證記錄和服務設定記錄) 之間的關聯性是透過導覽屬性進行公開。 將目標設為要求中的這些導覽屬性,即可讀取這些關聯性。
取得網域的驗證記錄 (預覽)
透過 verificationDnsRecords 導覽屬性取得網域的驗證記錄。
除非您已經順利地驗證您擁有網域,否則無法搭配使用該網域與 Azure AD 租用戶。 若要驗證網域的擁有權,您必須先擷取需要新增至網域區域檔案的一組網域驗證記錄。
成功時,傳回 [DomainDnsRecord] 物件集合;否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。
注意︰您可以將 "$links" 區段新增至 URL,以傳回 [DomainDnsRecord] 的連結。
{
"api": "Domains",
"operation": "get domain verification records",
"showComponents": {
"codeGenerator": "true",
"tryFeature": "false"
}
}
取得網域的服務設定記錄 (預覽)
透過 serviceConfigurationRecords 導覽屬性取得網域的服務設定記錄。
順利確認網域擁有權並指出您打算與網域搭配使用的服務之後,即可要求 Azure AD 傳回您需要新增至網域區域檔案的一組 DNS 記錄,讓服務可以與您的網域一起正常運作。
成功時,傳回 [DomainDnsRecord] 物件集合;否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。
注意︰您可以將 "$links" 區段新增至 URL,以傳回 [DomainDnsRecord] 的連結。
{
"api": "Domains",
"operation": "get domain service configuration records",
"showComponents": {
"codeGenerator": "true",
"tryFeature": "false"
}
}
網域的函數和動作 (預覽)
您可以在網域上呼叫下列動作。
確認動作 (預覽)
您可以在未驗證網域上呼叫 [verify] 動作 (isVerified 屬性是 false) 驗證網域的擁有權。
其他資源
- 在 Graph API 概念中深入了解 Graph API 支援的功能、能力和預覽功能。
Get domains
GET https://graph.windows.net/myorganization/domains?api-version
Parameter | Type | Value | Notes |
---|---|---|---|
Query | |||
api-version | string | 1.6 | The version of the Graph API to target. Only '1.6' is supported. Required. |
Response
Status Code:200
Content-Type: application/json
{
"odata.metadata": "https://graph.windows.net/contoso.onmicrosoft.com/$metadata#domains",
"value": [
{
"authenticationType": "Managed",
"availabilityStatus": null,
"adminManaged": true,
"isDefault": true,
"isInitial": true,
"isRoot": true,
"isVerified": true,
"name": "contoso.onmicrosoft.com",
"supportedServices": [
"Email",
"OfficeCommunicationsOnline"
]
}
]
}
Response List
Status Code | Description |
---|---|
200 | OK. Indicates success. The results are returned in the response body. |
Code Samples
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
/* OAuth2 is required to access this API. For more information visit:
https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */
// Specify values for the following required parameters
queryString["api-version"] = "1.6";
// Specify values for path parameters (shown as {...})
var uri = "https://graph.windows.net/myorganization/domains?" + queryString;
var response = await client.GetAsync(uri);
if (response.Content != null)
{
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
}
}
@ECHO OFF
REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/domains?api-version=1.6&"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample {
public static void main(String[] args) {
HttpClient httpclient = HttpClients.createDefault();
try
{
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/domains");
// Specify values for the following required parameters
builder.setParameter("api-version", "1.6");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
var params = {
// Specify values for the following required parameters
'api-version': "1.6",
};
$.ajax({
// Specify values for path parameters (shown as {...})
url: 'https://graph.windows.net/myorganization/domains?' + $.param(params),
type: 'GET',
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
NSString* path = @"https://graph.windows.net/myorganization/domains";
NSArray* array = @[
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if(nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if(nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);
$query_params = array(
// Specify values for the following required parameters
'api-version' => '1.6',
);
$request = new Http_Request2('https://graph.windows.net/myorganization/domains');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
$url = $request->getUrl();
$url->setQueryVariables($query_params);
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = httplib.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.parse.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = http.client.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://graph.windows.net/myorganization/domains')
uri.query = URI.encode_www_form({
# Specify values for the following required parameters
'api-version' => '1.6',
})
request = Net::HTTP::Get.new(uri.request_uri)
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body
Get a domain
GET https://graph.windows.net/myorganization/domains({domain_name})?api-version
Parameter | Type | Value | Notes |
---|---|---|---|
URL | ----- | ----- | ------ |
domain_name | string | 'contoso.onmicrosoft.com' | The fully qualified domain name of the target domain. Must be enclosed in single quotes. |
Query | ----- | ----- | ------ |
api-version | string | 1.6 | Specifies the version of the Graph API to target. Only '1.6' is supported. Required. |
GET https://graph.windows.net/myorganization/domains('contoso.onmicrosoft.com')?api-version=1.6
Response
Status Code:200
Content-Type: application/json
{
"odata.metadata": "https://graph.windows.net/myorganization/$metadata#domains/@Element",
"authenticationType": "Managed",
"availabilityStatus": null,
"AdminManaged": true,
"isDefault": true,
"isInitial": true,
"isRoot": true,
"isVerified": true,
"name": "contoso.onmicrosoft.com",
"supportedServices": [
"Email",
"OfficeCommunicationsOnline"
]
}
Response List
Status Code | Description |
---|---|
200 | OK. Indicates success. The domain is returned in the response body. |
Code Samples
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
/* OAuth2 is required to access this API. For more information visit:
https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */
// Specify values for the following required parameters
queryString["api-version"] = "1.6";
// Specify values for path parameters (shown as {...})
var uri = "https://graph.windows.net/myorganization/domains({domain_name})?" + queryString;
var response = await client.GetAsync(uri);
if (response.Content != null)
{
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
}
}
@ECHO OFF
REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/domains({domain_name})?api-version=1.6&"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample {
public static void main(String[] args) {
HttpClient httpclient = HttpClients.createDefault();
try
{
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/domains({domain_name})");
// Specify values for the following required parameters
builder.setParameter("api-version", "1.6");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
var params = {
// Specify values for the following required parameters
'api-version': "1.6",
};
$.ajax({
// Specify values for path parameters (shown as {...})
url: 'https://graph.windows.net/myorganization/domains({domain_name})?' + $.param(params),
type: 'GET',
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
NSString* path = @"https://graph.windows.net/myorganization/domains({domain_name})";
NSArray* array = @[
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if(nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if(nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);
$query_params = array(
// Specify values for the following required parameters
'api-version' => '1.6',
);
$request = new Http_Request2('https://graph.windows.net/myorganization/domains({domain_name})');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
$url = $request->getUrl();
$url->setQueryVariables($query_params);
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = httplib.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains({domain_name})?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.parse.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = http.client.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains({domain_name})?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://graph.windows.net/myorganization/domains({domain_name})')
uri.query = URI.encode_www_form({
# Specify values for the following required parameters
'api-version' => '1.6',
})
request = Net::HTTP::Get.new(uri.request_uri)
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body
Create a domain
POST https://graph.windows.net/myorganization/domains?api-version
Parameter | Type | Value | Notes |
---|---|---|---|
Query | |||
api-version | string | 1.6 | The version of the Graph API to target. Only '1.6' is supported. Required. |
Body | ----- | ----- | ------ |
Content-Type: application/json | ----- | ----- | ------ |
{
"name": "contoso.com"
}
Response
Status Code:201
Content-Type: application/json
{
"odata.metadata": "https://graph.windows.net/contoso.onmicrosoft.com/$metadata#domains/@Element",
"authenticationType": "Managed",
"availabilityStatus": null,
"isAdminManaged": false,
"isDefault": false,
"isInitial": false,
"isRoot": false,
"isVerified": false,
"name": "contoso.com",
"supportedServices": []
}
Response List
Status Code | Description |
---|---|
201 | Created. Indicates success. The new domain is returned in the response body. |
Update a domain
PATCH https://graph.windows.net/myorganization/domains({domain_name})?api-version
Parameter | Type | Value | Notes |
---|---|---|---|
URL | |||
domain_name | string | 'contoso.com' | The fully qualified domain name of the target domain. Must be enclosed in single quotes. |
Query | |||
api-version | string | 1.6 | The version of the Graph API to target. Only '1.6' is supported. Required. |
Body | ----- | ----- | ------ |
Content-Type: application/json | ----- | ----- | ------ |
{
"isDefault": true
}
PATCH https://graph.windows.net/myorganization/domains('contoso.com')?api-version=1.6
Response
Status Code:204
Content-Type: application/json
Response List
Status Code | Description |
---|---|
204 | No Content. Indicates success. No response body is returned. |
Delete a domain
DELETE https://graph.windows.net/myorganization/domains({domain_name})[?api-version]
Parameter | Type | Value | Notes |
---|---|---|---|
URL | |||
domain_name | string | 'contoso.com' | The fully qualified domain name of the target domain. Must be enclosed in single quotes. |
Query | |||
api-version | string | 1.6 | Specifies the version of the Graph API to target. Only '1.6' is supported. Required. |
DELETE https://graph.windows.net/myorganization/domains('contoso.com')?api-version=1.6
Response
Status Code:204
Content-Type: application/json
Response List
Status Code | Description |
---|---|
204 | No Content. Indicates success. |
Get a domain's verification records
GET https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords?api-version
Parameter | Type | Value | Notes |
---|---|---|---|
URL | |||
domain_name | string | 'contoso.com' | The fully qualified domain name of the target domain. Must be enclosed in single quotes. |
Query | |||
api-version | string | 1.6 | The version of the Graph API to target. Only '1.6' is supported. Required. |
GET https://graph.windows.net/myorganization/domains('contoso.com')/verificationDnsRecords?api-version=1.6
Response
Status Code:204
Content-Type: application/json
{
"odata.metadata": "https://graph.windows.net/myorganization/$metadata#domainDnsRecords",
"value": [
{
"odata.type": "Microsoft.DirectoryServices.DomainDnsTxtRecord",
"dnsRecordId": "aceff52c-06a5-447f-ac5f-256ad243cc5c",
"isOptional": false,
"label": "contoso.com",
"recordType": "Txt",
"supportedService": null,
"ttl": 3600,
"text": "MS=ms86120656"
},
{
"odata.type": "Microsoft.DirectoryServices.DomainDnsMxRecord",
"dnsRecordId": "5fbde38c-0865-497f-82b1-126f596bcee9",
"isOptional": false,
"label": "contoso.com",
"recordType": "Mx",
"supportedService": null,
"ttl": 3600,
"mailExchange": "ms86120656.msv1.invalid",
"preference": 32767
}
]
}
Response List
Status Code | Description |
---|---|
200 | OK. Indicates success. The results are returned in the response body. |
Code Samples
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
/* OAuth2 is required to access this API. For more information visit:
https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */
// Specify values for the following required parameters
queryString["api-version"] = "1.6";
// Specify values for path parameters (shown as {...})
var uri = "https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords?" + queryString;
var response = await client.GetAsync(uri);
if (response.Content != null)
{
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
}
}
@ECHO OFF
REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords?api-version=1.6&"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample {
public static void main(String[] args) {
HttpClient httpclient = HttpClients.createDefault();
try
{
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords");
// Specify values for the following required parameters
builder.setParameter("api-version", "1.6");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
var params = {
// Specify values for the following required parameters
'api-version': "1.6",
};
$.ajax({
// Specify values for path parameters (shown as {...})
url: 'https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords?' + $.param(params),
type: 'GET',
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
NSString* path = @"https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords";
NSArray* array = @[
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if(nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if(nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);
$query_params = array(
// Specify values for the following required parameters
'api-version' => '1.6',
);
$request = new Http_Request2('https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
$url = $request->getUrl();
$url->setQueryVariables($query_params);
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = httplib.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains({domain_name})/verificationDnsRecords?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.parse.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = http.client.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains({domain_name})/verificationDnsRecords?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://graph.windows.net/myorganization/domains({domain_name})/verificationDnsRecords')
uri.query = URI.encode_www_form({
# Specify values for the following required parameters
'api-version' => '1.6',
})
request = Net::HTTP::Get.new(uri.request_uri)
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body
Get a domain's service configuration records
GET https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords?api-version
Parameter | Type | Value | Notes |
---|---|---|---|
URL | ----- | ----- | ------ |
domain_name | string | 'contoso.com' | The fully qualified domain name of the target domain. Must be enclosed in single quotes. |
Query | ----- | ----- | ------ |
api-version | string | 1.6 | The version of the Graph API to target. Only '1.6' is supported. Required. |
GET https://graph.windows.net/myorganization/domains('contoso.com')/serviceConfigurationRecords?api-version=1.6
Response
Status Code:200
Content-Type: application/json
{
"odata.metadata": "https://graph.windows.net/myorganization/$metadata#domainDnsRecords",
"value": [
{
"odata.type": "Microsoft.DirectoryServices.DomainDnsMxRecord",
"dnsRecordId": "2b672ab0-0bee-476f-b334-be436f2449bd",
"isOptional": false,
"label": "contoso.com",
"recordType": "Mx",
"supportedService": "Email",
"ttl": 3600,
"mailExchange": "contoso-com.mail.protection.outlook.com",
"preference": 0
},
{
"odata.type": "Microsoft.DirectoryServices.DomainDnsTxtRecord",
"dnsRecordId": "62bea837-a0d7-4466-b6d9-ff6bd1db8671",
"isOptional": false,
"label": "contoso.com",
"recordType": "Txt",
"supportedServices": "Email",
"ttl": 3600,
"text": "v=spf1 include: spf.protection.outlook.com ~all"
},
{
"odata.type": "Microsoft.DirectoryServices.DomainDnsCnameRecord",
"dnsRecordId": "eea5ce9e-8deb-4ab7-a114-13ed6215774f",
"isOptional": false,
"label": "autodiscover.contoso.com",
"recordType": "CName",
"supportedServices": "Email",
"ttl": 3600,
"canonicalName": "autodiscover.outlook.com"
}
]
}
Response List
Status Code | Description |
---|---|
200 | OK. Indicates success. The results are returned in the response body. |
Code Samples
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
/* OAuth2 is required to access this API. For more information visit:
https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */
// Specify values for the following required parameters
queryString["api-version"] = "1.6";
// Specify values for path parameters (shown as {...})
var uri = "https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords?" + queryString;
var response = await client.GetAsync(uri);
if (response.Content != null)
{
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
}
}
@ECHO OFF
REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords?api-version=1.6&"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample {
public static void main(String[] args) {
HttpClient httpclient = HttpClients.createDefault();
try
{
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords");
// Specify values for the following required parameters
builder.setParameter("api-version", "1.6");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
var params = {
// Specify values for the following required parameters
'api-version': "1.6",
};
$.ajax({
// Specify values for path parameters (shown as {...})
url: 'https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords?' + $.param(params),
type: 'GET',
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
// Specify values for path parameters (shown as {...})
NSString* path = @"https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords";
NSArray* array = @[
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if(nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if(nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);
$query_params = array(
// Specify values for the following required parameters
'api-version' => '1.6',
);
$request = new Http_Request2('https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);
// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
$url = $request->getUrl();
$url->setQueryVariables($query_params);
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = httplib.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains({domain_name})/serviceConfigurationRecords?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
headers = {
}
params = urllib.parse.urlencode({
# Specify values for the following required parameters
'api-version': '1.6',
})
try:
conn = http.client.HTTPSConnection('graph.windows.net')
# Specify values for path parameters (shown as {...}) and request body if needed
conn.request("GET", "/myorganization/domains({domain_name})/serviceConfigurationRecords?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://graph.windows.net/myorganization/domains({domain_name})/serviceConfigurationRecords')
uri.query = URI.encode_www_form({
# Specify values for the following required parameters
'api-version' => '1.6',
})
request = Net::HTTP::Get.new(uri.request_uri)
# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body