Se requiere uno de los siguientes permisos para llamar a esta API. Para obtener más información, incluido cómo elegir permisos, vea Permisos.
Tipo de permiso
Permisos (de menos a más privilegiados)
Delegado (cuenta profesional o educativa)
Contacts.ReadWrite
Delegado (cuenta personal de Microsoft)
Contacts.ReadWrite
Aplicación
Contacts.ReadWrite
Solicitud HTTP
POST /me/contacts
POST /users/{id | userPrincipalName}/contacts
POST /me/contactFolders/{id}/contacts
POST /users/{id | userPrincipalName}/contactFolders/{id}/contacts
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Contact
{
ParentFolderId = "parentFolderId-value",
Birthday = DateTimeOffset.Parse("datetime-value"),
FileAs = "fileAs-value",
DisplayName = "displayName-value",
GivenName = "givenName-value",
Initials = "initials-value",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.ContactFolders["{contactFolder-id}"].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.setParentFolderId("parentFolderId-value");
OffsetDateTime birthday = OffsetDateTime.parse("datetime-value");
contact.setBirthday(birthday);
contact.setFileAs("fileAs-value");
contact.setDisplayName("displayName-value");
contact.setGivenName("givenName-value");
contact.setInitials("initials-value");
Contact result = graphClient.me().contactFolders().byContactFolderId("{contactFolder-id}").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
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Contact(
parent_folder_id = "parentFolderId-value",
birthday = "datetime-value",
file_as = "fileAs-value",
display_name = "displayName-value",
given_name = "givenName-value",
initials = "initials-value",
)
result = await graph_client.me.contact_folders.by_contact_folder_id('contactFolder-id').contacts.post(request_body)