Namespace: microsoft.graph
Wichtig
Die APIs unter der /beta Version in Microsoft Graph können sich ändern. Die Verwendung dieser APIs in Produktionsanwendungen wird nicht unterstützt. Um festzustellen, ob eine API in v1.0 verfügbar ist, verwenden Sie die Version Selektor.
Dient zum Hinzufügen eines Kontakts zum Stammordner der Kontakte oder zum Endpunkt contacts eines anderen Kontaktordners.
Diese API ist in den folgenden nationalen Cloudbereitstellungen verfügbar.
| Weltweiter Service |
US Government L4 |
US Government L5 (DOD) |
China, betrieben von 21Vianet |
| ✅ |
✅ |
✅ |
✅ |
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie unter Berechtigungen.
| Berechtigungstyp |
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten) |
| Delegiert (Geschäfts-, Schul- oder Unikonto) |
Contacts.ReadWrite |
| Delegiert (persönliches Microsoft-Konto) |
Contacts.ReadWrite |
| Anwendung |
Contacts.ReadWrite |
HTTP-Anforderung
POST /me/contacts
POST /users/{id | userPrincipalName}/contacts
POST /me/contactFolders/{id}/contacts
POST /users/{id | userPrincipalName}/contactFolders/{id}/contacts
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung des Contact-Objekts an.
Antwort
Wenn die Methode erfolgreich verläuft, werden der Antwortcode 201 Created und das Contact-Objekt im Antworttext zurückgegeben.
Beispiel
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
POST https://graph.microsoft.com/beta/me/contactFolders/{id}/contacts
Content-type: application/json
{
"parentFolderId": "parentFolderId-value",
"birthday": "2016-10-19T10:37:00Z",
"fileAs": "fileAs-value",
"displayName": "displayName-value",
"givenName": "givenName-value",
"initials": "initials-value"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Contact
{
ParentFolderId = "parentFolderId-value",
Birthday = DateTimeOffset.Parse("2016-10-19T10:37:00Z"),
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 major version. Current major version is $v0.*
// Dependencies
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewContact()
parentFolderId := "parentFolderId-value"
requestBody.SetParentFolderId(&parentFolderId)
birthday , err := time.Parse(time.RFC3339, "2016-10-19T10:37:00Z")
requestBody.SetBirthday(&birthday)
fileAs := "fileAs-value"
requestBody.SetFileAs(&fileAs)
displayName := "displayName-value"
requestBody.SetDisplayName(&displayName)
givenName := "givenName-value"
requestBody.SetGivenName(&givenName)
initials := "initials-value"
requestBody.SetInitials(&initials)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
contacts, err := graphClient.Me().ContactFolders().ByContactFolderId("contactFolder-id").Contacts().Post(context.Background(), requestBody, nil)
// 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("2016-10-19T10:37:00Z");
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);
const options = {
authProvider,
};
const client = Client.init(options);
const contact = {
parentFolderId: 'parentFolderId-value',
birthday: '2016-10-19T10:37:00Z',
fileAs: 'fileAs-value',
displayName: 'displayName-value',
givenName: 'givenName-value',
initials: 'initials-value'
};
await client.api('/me/contactFolders/{id}/contacts')
.version('beta')
.post(contact);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Contact;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Contact();
$requestBody->setParentFolderId('parentFolderId-value');
$requestBody->setBirthday(new \DateTime('2016-10-19T10:37:00Z'));
$requestBody->setFileAs('fileAs-value');
$requestBody->setDisplayName('displayName-value');
$requestBody->setGivenName('givenName-value');
$requestBody->setInitials('initials-value');
$result = $graphServiceClient->me()->contactFolders()->byContactFolderId('contactFolder-id')->contacts()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.PersonalContacts
$params = @{
parentFolderId = "parentFolderId-value"
birthday = [System.DateTime]::Parse("2016-10-19T10:37:00Z")
fileAs = "fileAs-value"
displayName = "displayName-value"
givenName = "givenName-value"
initials = "initials-value"
}
# A UPN can also be used as -UserId.
New-MgBetaUserContactFolderContact -UserId $userId -ContactFolderId $contactFolderId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.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 = "2016-10-19T10:37:00Z",
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)
Geben Sie im Anforderungstext eine JSON-Darstellung des contact-Objekts an.
Antwort
Das folgende Beispiel zeigt die Antwort. Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt sein.
HTTP/1.1 200 OK
Content-type: application/json
{
"parentFolderId": "parentFolderId-value",
"birthday": "2016-10-19T10:37:00Z",
"fileAs": "fileAs-value",
"displayName": "displayName-value",
"givenName": "givenName-value",
"initials": "initials-value"
}