Share via


Opérations sur les contacts | Référence de l’API Graph

S’applique à : API Graph | Azure Active Directory

Cette rubrique explique comment effectuer des opérations sur les contacts professionnels à l’aide de l’API Azure Active Directory (AD) Graph. Les contacts professionnels correspondent généralement à des utilisateurs qui n’appartiennent pas à votre entreprise ou organisation. Ils sont différents des contacts personnels Outlook O365. Avec l’API Azure AD Graph, vous pouvez lire les contacts professionnels et leurs relations vers d’autres objets d’annuaire, comme leur responsable, leurs collaborateurs directs et leurs appartenances aux groupes. L’écriture de contacts professionnels est limitée aux contacts qui ne sont pas actuellement synchronisés à partir d’un annuaire local (la propriété dirSyncEnabled a pour valeur null ou false). S’agissant de tels contacts, vous pouvez mettre à jour ou supprimer le contact lui-même ou sa propriété manager. Vous ne pouvez pas créer de contacts professionnels avec l’API Graph. Pour plus d’informations sur les contacts professionnels, notamment sur la procédure de création de ceux-ci dans votre locataire, consultez contact.

L’API Graph est une API basée sur REST qui fournit un accès par programme aux objets d’annuaire d’Azure Active Directory tels que les utilisateurs, les groupes, les contacts professionnels et les applications.

Important

La fonctionnalité d’API Azure AD Graph est également disponible au moyen de Microsoft Graph, une API unifiée qui intègre aussi des API d’autres services Microsoft tels que Outlook, OneDrive, OneNote, Planner et Office Graph, tous accessibles par le biais d’un seul point de terminaison à l’aide d’un seul jeton d’accès.

Exécuter des opérations REST sur des contacts

Pour effectuer des opérations sur les contacts professionnels avec l’API Graph, vous devez envoyer des demandes HTTP à l’aide d’une méthode prise en charge (GET, POST, PATCH, PUT ou DELETE) à un point de terminaison qui cible la collection de ressources des contacts, un contact spécifique, une propriété de navigation d’un contact ou une fonction ou action pouvant être appelée sur un contact.

Les demandes d’API Graph utilisent l’URL de base suivante :

https://graph.windows.net/{tenant_id}/{resource_path}?{api_version}[odata_query_parameters]

Important

Les demandes envoyées à l’API Graph doivent être bien formées, cibler un point de terminaison et une version valides de l’API Graph et indiquer dans leur en-tête Authorization un jeton d’accès valide obtenu d’Azure AD. Pour plus d’informations sur la création de demandes et la réception de réponses au moyen de l’API Graph, consultez Operations Overview.

Vous spécifiez le {resource_path} différemment selon que vous ciblez la collection de tous les contacts de votre locataire, un contact individuel ou une propriété de navigation d’un contact spécifique.

  • /contacts cible la collection de ressources des contacts. Vous pouvez utiliser ce chemin d’accès aux ressources pour lire tous les contacts ou une liste filtrée de contacts dans votre locataire.
  • /contacts/{object_id} cible un contact individuel de votre locataire. Vous spécifiez le contact cible avec son ID d’objet (GUID). Ce chemin d’accès de ressource permet d’obtenir les propriétés déclarées d’un contact. Pour les contacts qui n’ont pas été synchronisés à partir d’un annuaire local, vous pouvez utiliser ce chemin d’accès de ressources pour modifier les propriétés déclarées d’un contact ou pour supprimer un contact.
  • /contacts/{object_id}/{nav_property} cible la propriété de navigation spécifiée d’un contact. Vous pouvez l’utiliser pour renvoyer le ou les objets référencés par la propriété de navigation cible du contact spécifié. Remarque : cette forme d’adressage est disponible uniquement pour les lectures.
  • /contacts/{object_id}/$links/{nav_property} cible la propriété de navigation spécifiée d’un contact. Vous pouvez utiliser cette forme d’adressage pour lire et modifier une propriété de navigation. Sur les lectures, les objets référencés par la propriété sont renvoyés sous la forme d’un ou plusieurs liens dans le corps de la réponse. Seule la propriété de navigation du responsable des contacts qui ne sont pas synchronisés à partir d’un annuaire local peut être modifiée. Le responsable est spécifié en tant que lien dans le corps de la demande.

Par exemple, la demande suivante renvoie un lien vers le responsable du contact spécifié :

GET https://graph.windows.net/myorganization/contacts/a2fb3752-08b4-413d-af6f-1d99c4c131d9/$links/manager?api-version=1.6

Opérations de base sur les contacts

Vous pouvez effectuer des opérations de lecture sur les contacts en ciblant la collection de ressources de contact ou un contact spécifique. Vous pouvez mettre à jour et supprimer des contacts qui n’ont pas été synchronisés à partir d’un annuaire local en ciblant un contact spécifique. L’API Graph ne prend pas en charge la création des contacts. Elle ne prend pas non plus en charge la mise à jour ou la suppression des contacts qui sont synchronisés à partir d’un annuaire local (la valeur de la propriété dirSyncEnabled est true). Les rubriques suivantes illustrent les procédures de base sur les contacts.


Obtenir des contacts

Obtient une collection de contacts. Vous pouvez ajouter des paramètres de requête OData à la demande pour filtrer, trier et paginer la réponse. Pour plus d’informations, consultez Supported Queries, Filters, and Paging Options.

En cas de réussite, renvoie une collection d’objets contact ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

GET https://graph.windows.net/myorganization/contacts?api-version

Parameters

ParameterTypeValueNotes
Query
api-versionstring

1.6

The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.Contact",
  "value": [
    {
      "odata.type": "Microsoft.DirectoryServices.Contact",
      "objectType": "Contact",
      "objectId": "31944231-fd52-4a7f-b32e-7902a01fddf9",
      "deletionTimestamp": null,
      "city": null,
      "companyName": null,
      "country": null,
      "department": null,
      "dirSyncEnabled": null,
      "displayName": "Marcus Breyer",
      "facsimileTelephoneNumber": null,
      "givenName": "Marcus",
      "jobTitle": null,
      "lastDirSyncTime": null,
      "mail": "Marcus@contoso.com",
      "mailNickname": "MarcusBreyer",
      "mobile": null,
      "physicalDeliveryOfficeName": null,
      "postalCode": null,
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:Marcus@contoso.com"
      ],
      "sipProxyAddress": null,
      "state": null,
      "streetAddress": null,
      "surname": "Breyer",
      "telephoneNumber": null
    },
    {
      "odata.type": "Microsoft.DirectoryServices.Contact",
      "objectType": "Contact",
      "objectId": "35110b16-360c-4c4a-93b2-03f065fabd93",
      "deletionTimestamp": null,
      "city": null,
      "companyName": null,
      "country": null,
      "department": null,
      "dirSyncEnabled": null,
      "displayName": "Yossi Ran",
      "facsimileTelephoneNumber": null,
      "givenName": "Yossi",
      "jobTitle": null,
      "lastDirSyncTime": null,
      "mail": "Yossi@contoso.com",
      "mailNickname": "YossiRan",
      "mobile": null,
      "physicalDeliveryOfficeName": null,
      "postalCode": null,
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:Yossi@contoso.com"
      ],
      "sipProxyAddress": null,
      "state": null,
      "streetAddress": null,
      "surname": "Ran",
      "telephoneNumber": null
    },
    {
      "odata.type": "Microsoft.DirectoryServices.Contact",
      "objectType": "Contact",
      "objectId": "7163f3b8-70c9-43d2-b9e1-4467ddaf087a",
      "deletionTimestamp": null,
      "city": null,
      "companyName": null,
      "country": null,
      "department": null,
      "dirSyncEnabled": null,
      "displayName": "Jeremy Nelson",
      "facsimileTelephoneNumber": null,
      "givenName": "Jeremy",
      "jobTitle": null,
      "lastDirSyncTime": null,
      "mail": "Jeremy@contoso.com",
      "mailNickname": "JeremyNelson",
      "mobile": null,
      "physicalDeliveryOfficeName": null,
      "postalCode": null,
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:Jeremy@contoso.com"
      ],
      "sipProxyAddress": null,
      "state": null,
      "streetAddress": null,
      "surname": "Nelson",
      "telephoneNumber": null
    },
    {
      "odata.type": "Microsoft.DirectoryServices.Contact",
      "objectType": "Contact",
      "objectId": "83234b5c-3a10-4108-8f36-39b1addadfdb",
      "deletionTimestamp": null,
      "city": null,
      "companyName": null,
      "country": null,
      "department": null,
      "dirSyncEnabled": null,
      "displayName": "David Strome",
      "facsimileTelephoneNumber": null,
      "givenName": "David",
      "jobTitle": null,
      "lastDirSyncTime": null,
      "mail": "David@contoso.com",
      "mailNickname": "DavidStrome",
      "mobile": null,
      "physicalDeliveryOfficeName": null,
      "postalCode": null,
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:David@contoso.com"
      ],
      "sipProxyAddress": null,
      "state": null,
      "streetAddress": null,
      "surname": "Strome",
      "telephoneNumber": null
    },
    {
      "odata.type": "Microsoft.DirectoryServices.Contact",
      "objectType": "Contact",
      "objectId": "8c1315ce-bf6f-4e26-b24f-c830606ef41c",
      "deletionTimestamp": null,
      "city": null,
      "companyName": null,
      "country": null,
      "department": null,
      "dirSyncEnabled": null,
      "displayName": "Holly Holt",
      "facsimileTelephoneNumber": null,
      "givenName": "Holly",
      "jobTitle": null,
      "lastDirSyncTime": null,
      "mail": "Holly@contoso.com",
      "mailNickname": "HollyHolt",
      "mobile": null,
      "physicalDeliveryOfficeName": null,
      "postalCode": null,
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:Holly@contoso.com"
      ],
      "sipProxyAddress": null,
      "state": null,
      "streetAddress": null,
      "surname": "Holt",
      "telephoneNumber": null
    }
  ]
}

Response List

Status CodeDescription
200OK. Indicates success. The results are returned in the response body.

Code Samples

require 'net/http'

uri = URI('https://graph.windows.net/myorganization/contacts')

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
@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/contacts?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/contacts");
		// 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/contacts?' + $.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/contacts";
    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/contacts');
$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/contacts?%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/contacts?%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/contacts')

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

Créer un contact

Obtient un contact spécifié. Vous identifiez le contact cible à l’aide de l’ID d’objet (GUID).

En cas de réussite, renvoie l’objet contact du contact spécifié ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

GET https://graph.windows.net/myorganization/contacts/{object_id}?api-version

Parameters

ParameterTypeValueNotes
URL
object_idstring

31944231-fd52-4a7f-b32e-7902a01fddf9

The object ID (GUID) of the target contact.
Query
api-versionstring

1.6

Specifies the version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/contacts/31944231-fd52-4a7f-b32e-7902a01fddf9?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/graphdir1.onmicrosoft.com/$metadata#directoryObjects/Microsoft.DirectoryServices.Contact/@Element",
  "odata.type": "Microsoft.DirectoryServices.Contact",
  "objectType": "Contact",
  "objectId": "31944231-fd52-4a7f-b32e-7902a01fddf9",
  "deletionTimestamp": null,
  "city": null,
  "companyName": null,
  "country": null,
  "department": null,
  "dirSyncEnabled": null,
  "displayName": "Marcus Breyer",
  "facsimileTelephoneNumber": null,
  "givenName": "Marcus",
  "jobTitle": null,
  "lastDirSyncTime": null,
  "mail": "Marcus@contoso.com",
  "mailNickname": "MarcusBreyer",
  "mobile": null,
  "physicalDeliveryOfficeName": null,
  "postalCode": null,
  "provisioningErrors": [],
  "proxyAddresses": [
    "SMTP:Marcus@contoso.com"
  ],
  "sipProxyAddress": null,
  "state": null,
  "streetAddress": null,
  "surname": "Breyer",
  "telephoneNumber": null
}

Response List

Status CodeDescription
200OK. Indicates success. The contact 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/contacts/{object_id}?" + 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/contacts/{object_id}?api-version=1.6&amp;"^
// 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/contacts/{object_id}");
		// 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/contacts/{object_id}?' + $.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/contacts/{object_id}";
    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/contacts/{object_id}');
$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/contacts/{object_id}?%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/contacts/{object_id}?%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/contacts/{object_id}')

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

Mettre à jour un contact

Mettez à jour les propriétés d’un contact. Spécifiez toute propriété contact accessible en écriture dans le corps de la demande. Seules les propriétés que vous spécifiez sont modifiées. Vous pouvez mettre à niveau uniquement les contacts qui n’ont pas été synchronisés à partir d’un annuaire local (la valeur de la propriété dirSyncEnabled est null ou false).

En cas de réussite, aucun corps de réponse n’est renvoyé ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

PATCH https://graph.windows.net/myorganization/contacts/{object_id}?api-version

Parameters

ParameterTypeValueNotes
URL
object_idstring

7163f3b8-70c9-43d2-b9e1-4467ddaf087a

The object ID (GUID) of the target contact.
Query
api-versionstring

1.6

The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
Body

Content-Type: application/json

{
  "department": "Sales",
  "jobTitle": "Sales Rep"
}
PATCH https://graph.windows.net/myorganization/contacts/7163f3b8-70c9-43d2-b9e1-4467ddaf087a?api-version=1.6

Response

Status Code:204

Content-Type: application/json

none

Response List

Status CodeDescription
204No Content. Indicates success. No response body is returned.

Supprimer un contact

Supprime un contact. Vous pouvez supprimer uniquement les contacts qui n’ont pas été synchronisés à partir d’un annuaire local (la valeur de la propriété dirSyncEnabled est null ou false).

En cas de réussite, aucun corps de réponse n’est renvoyé ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

DELETE https://graph.windows.net/myorganization/contacts/{object_id}[?api-version]

Parameters

ParameterTypeValueNotes
URL
object_idstring

7163f3b8-70c9-43d2-b9e1-4467ddaf087a

The object ID (GUID) of the target contact.
Query
api-versionstring

1.6

Specifies the version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
DELETE https://graph.windows.net/myorganization/contacts/7163f3b8-70c9-43d2-b9e1-4467ddaf087a?api-version=1.6

Response

Status Code:204

Content-Type: application/json

none

Response List

Status CodeDescription
204No Content. Indicates success.

Opérations sur les propriétés de navigation du contact

Les relations entre un contact et d’autres objets de l’annuaire tels que le responsable du contact, les appartenances directes aux groupes et les collaborateurs directs sont exposées via les propriétés de navigation. Vous pouvez lire et dans certains cas modifier ces relations en ciblant ces propriétés de navigation dans vos demandes.

Obtenir le responsable d’un contact

Obtient le responsable du contact à partir de la propriété de navigation manager.

En cas de réussite, renvoie un lien vers l’User ou le contact assigné en tant que responsable du contact ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

Remarque : vous pouvez supprimer le segment « $links » de l’URL pour renvoyer l’objet User ou contact au lieu d’un lien.

GET https://graph.windows.net/myorganization/contacts/{object_id}/$links/manager?api-version

Parameters

ParameterTypeValueNotes
URL
object_idstring

31944231-fd52-4a7f-b32e-7902a01fddf9

The object ID (GUID) of the target contact.
Query
api-versionstring

1.6

The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/contacts/31944231-fd52-4a7f-b32e-7902a01fddf9/$links/manager?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/$links/manager",
  "url": "https://graph.windows.net/myorganization/directoryObjects/35110b16-360c-4c4a-93b2-03f065fabd93/Microsoft.WindowsAzure.ActiveDirectory.Contact"
}

Response List

Status CodeDescription
200OK. Indicates success. A link to the contact's manager is returned.
404Not Found. The requested resource was not found. This can occur if the manager property is not currently set for the specified contact. It can also have other causes, for example, a bad domain. A code and associated message is returned with the error.

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/contacts/{object_id}/$links/manager?" + 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/contacts/{object_id}/$links/manager?api-version=1.6&amp;"^
// 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/contacts/{object_id}/$links/manager");
		// 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/contacts/{object_id}/$links/manager?' + $.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/contacts/{object_id}/$links/manager";
    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/contacts/{object_id}/$links/manager');
$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/contacts/{object_id}/$links/manager?%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/contacts/{object_id}/$links/manager?%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/contacts/{object_id}/$links/manager')

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

Assigner le responsable d’un contact

Assigne le responsable d’un contact via la propriété manager. Un utilisateur ou un contact peut être assigné. Le corps de la demande contient un lien vers l’User ou le contact à assigner. Vous pouvez mettre à niveau uniquement le responsable des contacts qui n’ont pas été synchronisés à partir d’un annuaire local (la valeur de la propriété dirSyncEnabled est null ou false).

En cas de réussite, aucun corps de réponse n’est renvoyé ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

PUT https://graph.windows.net/myorganization/contacts/{object_id}/$links/manager?api-version

Parameters

ParameterTypeValueNotes
URL
object_idstring

31944231-fd52-4a7f-b32e-7902a01fddf9

The object ID (GUID) of the target contact.
Query
api-versionstring

1.6

The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
Body

Content-Type: application/json

{
  "url": "https://graph.windows.net/myorganization/directoryObjects/35110b16-360c-4c4a-93b2-03f065fabd93"
}
PUT https://graph.windows.net/myorganization/contacts/31944231-fd52-4a7f-b32e-7902a01fddf9/$links/manager?api-version=1.6

Response

Status Code:204

Content-Type: application/json

none

Response List

Status CodeDescription
204No Content. Indicates success. No response body is returned.

Obtenir les collaborateurs directs d’un contact

Obtient les collaborateurs directs du contact à partir de la propriété de navigation directReports.

En cas de réussite, renvoie une collection de liens vers les Users et les contacts à qui ce contact est assigné en tant que responsable ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

Remarque : vous pouvez supprimer le segment « $links » de l’URL pour renvoyer des DirectoryObjects pour les utilisateurs et les contacts au lieu de liens.

GET https://graph.windows.net/myorganization/contacts/{object_id}/$links/directReports?api-version

Parameters

ParameterTypeValueNotes
URL
object_idstring

31944231-fd52-4a7f-b32e-7902a01fddf9

The object ID (GUID) of the target contact.
Query
api-versionstring

1.6

The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/contacts/31944231-fd52-4a7f-b32e-7902a01fddf9/$links/directReports?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/$links/directReports",
  "value": [
    {
      "url": "https://graph.windows.net/myorganization/directoryObjects/8c1315ce-bf6f-4e26-b24f-c830606ef41c/Microsoft.DirectoryServices.Contact"
    }
  ]
}

Response List

Status CodeDescription
200OK. Indicates success. One or more direct reports are returned.

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/contacts/{object_id}/$links/directReports?" + 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/contacts/{object_id}/$links/directReports?api-version=1.6&amp;"^
// 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/contacts/{object_id}/$links/directReports");
		// 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/contacts/{object_id}/$links/directReports?' + $.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/contacts/{object_id}/$links/directReports";
    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/contacts/{object_id}/$links/directReports');
$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/contacts/{object_id}/$links/directReports?%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/contacts/{object_id}/$links/directReports?%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/contacts/{object_id}/$links/directReports')

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

Obtenir les appartenances aux groupes d’un contact

Obtient les appartenances aux groupes du contact à partir de la propriété de navigation memberOf.

Cette propriété renvoie uniquement les groupes dont le contact est membre direct. Pour obtenir tous les groupes dont le contact est membre direct ou transitif, appelez la fonction getMemberGroups.

En cas de réussite, renvoie une collection de liens vers les Groups dont ce contact est membre ; sinon, le corps de la réponse contient les détails de l’erreur. Pour plus d’informations sur les erreurs, consultez Error Codes and Error Handling.

Remarque : vous pouvez supprimer le segment « $links » de l’URL pour renvoyer les DirectoryObjects pour les groupes au lieu de liens.

GET https://graph.windows.net/myorganization/contacts/{object_id}/$links/memberOf?api-version

Parameters

ParameterTypeValueNotes
URL
object_idstring

31944231-fd52-4a7f-b32e-7902a01fddf9

The object ID (GUID) of the target contact.
Query
api-versionstring

1.6

The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/contacts/31944231-fd52-4a7f-b32e-7902a01fddf9/$links/memberOf?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/$links/memberOf",
  "value": [
    {
      "url": "https://graph.windows.net/myorganization/directoryObjects/12345678-b942-47c9-a10e-a4bee353ce60/Microsoft.DirectoryServices.Group"
    }
  ]
}

Response List

Status CodeDescription
200OK. Indicates success. One or more groups and/or directory roles are returned.

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/contacts/{object_id}/$links/memberOf?" + 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/contacts/{object_id}/$links/memberOf?api-version=1.6&amp;"^
// 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/contacts/{object_id}/$links/memberOf");
		// 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/contacts/{object_id}/$links/memberOf?' + $.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/contacts/{object_id}/$links/memberOf";
    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/contacts/{object_id}/$links/memberOf');
$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/contacts/{object_id}/$links/memberOf?%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/contacts/{object_id}/$links/memberOf?%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/contacts/{object_id}/$links/memberOf')

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

Fonctions et actions sur les contacts

Vous pouvez appeler les fonctions suivantes sur un contact.

Vérifier l’appartenance dans un groupe spécifique (opération transitive)

Vous pouvez appeler la fonction isMemberOf pour vérifier l’appartenance dans un groupe spécifique. La vérification est transitive.

Vérifier l’appartenance dans une liste de groupes (opération transitive)

Vous pouvez appeler la fonction checkMemberGroups pour vérifier l’appartenance dans une liste de groupes. La vérification est transitive.

Obtenir toutes les appartenances aux groupes (opération transitive)

Vous pouvez appeler la fonction getMemberGroups pour renvoyer tous les groupes dont le contact est membre. La vérification est transitive, contrairement à la lecture de la propriété de navigation memberOf, qui renvoie uniquement les groupes dont le contact est membre direct.

Ressources supplémentaires

  • Pour en savoir plus sur les fonctionnalités prises en charge, les capacités et les fonctionnalités en version préliminaire de l’API Graph, consultez Concepts de l’API Graph.