Makale
01/20/2022
Okumak için 2 dakika
10 katılımcı
Bu makalede
Namespace: microsoft.graph
Delete a contact.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Contacts.ReadWrite
Delegated (personal Microsoft account)
Contacts.ReadWrite
Application
Contacts.ReadWrite
HTTP request
A contact from a user's default contactFolder .
DELETE /me/contacts/{id}
DELETE /users/{id | userPrincipalName}/contacts/{id}
A contact from a user's top level contactFolder .
DELETE /me/contactFolders/{id}/contacts/{id}
DELETE /users/{id | userPrincipalName}/contactFolders/{id}/contacts/{id}
A contact contained in a child folder of a contactFolder . The
example below shows one level of nesting, but a contact can be located in a child of a child and so on.
DELETE /me/contactFolders/{id}/childFolders/{id}/.../contacts/{id}
DELETE /users/{id | userPrincipalName}/contactFolders/{id}/childFolders/{id}/contacts/{id}
Header
Value
Authorization
Bearer {token}. Required.
Request body
Do not supply a request body for this method.
Response
If successful, this method returns 204 No Content
response code. It does not return anything in the response body.
Example
Request
Here is an example of the request.
DELETE https://graph.microsoft.com/v1.0/me/contacts/{id}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
await graphClient.Me.Contacts["{contact-id}"]
.Request()
.DeleteAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/contacts/{id}"]]];
[urlRequest setHTTPMethod:@"DELETE"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
graphClient.me().contacts("{id}")
.buildRequest()
.delete();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
contactId := "contact-id"
graphClient.Me().ContactsById(&contactId).Delete()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.PersonalContacts
# A UPN can also be used as -UserId.
Remove-MgUserContact -UserId $userId -ContactId $contactId
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
Here is an example of the response. Note: The response object shown here might be shortened for readability.
HTTP/1.1 204 No Content