L’une des autorisations suivantes est nécessaire pour appeler cette API. Pour plus d’informations, notamment sur la façon de choisir les autorisations, voir Autorisations.
Type d’autorisation
Autorisations (de celle qui offre le plus de privilèges à celle qui en offre le moins)
Déléguée (compte professionnel ou scolaire)
Contacts.ReadWrite
Déléguée (compte Microsoft personnel)
Contacts.ReadWrite
Application
Contacts.ReadWrite
Requête HTTP
POST /me/contacts
POST /users/{id | userPrincipalName}/contacts
POST /me/contactFolders/{contactFolderId}/contacts
POST /users/{id | userPrincipalName}/contactFolders/{contactFolderId}/contacts
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Contact
{
GivenName = "Pavel",
Surname = "Bansky",
EmailAddresses = new List<EmailAddress>
{
new EmailAddress
{
Address = "pavelb@contoso.com",
Name = "Pavel Bansky",
},
},
BusinessPhones = new List<string>
{
"+1 732 555 0102",
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Contacts.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Contact contact = new Contact();
contact.setGivenName("Pavel");
contact.setSurname("Bansky");
LinkedList<EmailAddress> emailAddresses = new LinkedList<EmailAddress>();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("pavelb@contoso.com");
emailAddress.setName("Pavel Bansky");
emailAddresses.add(emailAddress);
contact.setEmailAddresses(emailAddresses);
LinkedList<String> businessPhones = new LinkedList<String>();
businessPhones.add("+1 732 555 0102");
contact.setBusinessPhones(businessPhones);
Contact result = graphClient.me().contacts().post(contact);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.contact import Contact
from msgraph.generated.models.email_address import EmailAddress
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Contact(
given_name = "Pavel",
surname = "Bansky",
email_addresses = [
EmailAddress(
address = "pavelb@contoso.com",
name = "Pavel Bansky",
),
],
business_phones = [
"+1 732 555 0102",
],
)
result = await graph_client.me.contacts.post(request_body)