Contacts: delete
Stay organized with collections
Save and categorize content based on your preferences.
Requires authorization
Deletes a contact.
See an example.
Request
HTTP request
DELETE https://www.googleapis.com/mirror/v1/contacts/id
Parameters
Parameter name |
Value |
Description |
Path parameters |
id |
string |
The ID of the contact.
|
Authorization
This request requires authorization with the following scope (read more about authentication and authorization).
Scope |
https://www.googleapis.com/auth/glass.timeline |
Request body
Do not supply a request body with this method.
Response
If successful, this method returns an empty response body.
Examples
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).
Java
Uses the Java client library.
import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.Contact;
import java.io.IOException;
public class MyClass {
// ...
/**
* Delete a contact for the current user.
*
* @param service Authorized Mirror service.
* @param contactId ID of the Contact to delete.
*/
public static void deleteContact(Mirror service, String contactId) {
try {
service.contacts().delete(contactId).execute();
} catch (IOException e) {
System.err.println("An error occurred: " + e);
}
}
// ...
}
.NET
Uses the .NET client library.
using System;
using Google.Apis.Mirror.v1;
public class MyClass {
// ...
/// <summary>
/// Delete a contact for the current user.
/// </summary>
/// <param name='service'>Authorized Mirror service.</param>
/// <param name='contactId'>ID of the Contact to delete.</param>
public static void DeleteContact(MirrorService service,
String contactId) {
try {
service.Contacts.Delete(contactId).Fetch();
} catch (Exception e) {
Console.WriteLine("An error occurred: " + e.Message);
}
}
// ...
}
PHP
Uses the PHP client library.
/**
* Delete a contact for the current user.
*
* @param Google_MirrorService $service Authorized Mirror service.
* @param string $contactId ID of the Contact to delete.
*/
function deleteContact($service, $contactId) {
try {
$service->contacts->delete($contactId);
} catch (Exception $e) {
print 'An error occurred: ' . $e->getMessage();
}
}
Python
Uses the Python client library.
from apiclient import errors
# ...
def delete_contact(service, contact_id):
"""Delete a contact for the current user.
Args:
service: Authorized Mirror service.
contact_id: ID of the Contact to delete.
"""
try:
service.contacts().delete(contact_id).execute()
except errors.HttpError, error:
print 'An error occurred: %s' % error
Ruby
Uses the Ruby client library.
##
# Delete a contact for the current user.
#
# @param [Google::APIClient] client
# Authorized client instance.
# @param [String] contact_id
# ID of the contact to delete.
# @return nil
def delete_contact(client, contact_id)
mirror = client.discovered_api('mirror', 'v1')
result = client.execute(
:api_method => mirror.contacts.delete,
:parameters => { 'id' => contact_id })
if result.error?
puts "An error occurred: #{result.data['error']['message']}"
end
end
Go
Uses the Go client library.
import (
"code.google.com/p/google-api-go-client/mirror/v1"
"fmt"
)
// DeleteContact deletes a contact for the current user.
func DeleteContact(g *mirror.Service, contactId string) error {
err := g.Contacts.Delete(contactId).Do()
if err != nil {
fmt.Printf("An error occurred: %v\n", err)
}
return err
}
Raw HTTP
Does not use a client library.
DELETE /mirror/v1/contacts/harold HTTP/1.1
Authorization: Bearer auth token
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eDeletes a specified contact using the \u003ccode\u003eDELETE\u003c/code\u003e method and requires \u003ccode\u003eglass.timeline\u003c/code\u003e authorization scope.\u003c/p\u003e\n"],["\u003cp\u003eThe request takes the contact ID as a path parameter and does not require a request body.\u003c/p\u003e\n"],["\u003cp\u003eSuccessful execution returns an empty response body, indicating the contact has been deleted.\u003c/p\u003e\n"],["\u003cp\u003eCode samples demonstrate the deletion process using various client libraries like Java, .NET, PHP, Python, Ruby, and Go.\u003c/p\u003e\n"],["\u003cp\u003eRaw HTTP requests can also achieve the same functionality using the correct authorization token.\u003c/p\u003e\n"]]],[],null,["# Contacts: delete\n\n**Requires [authorization](#auth)**\n\nDeletes a contact.\n[See an example](#examples).\n\nRequest\n-------\n\n### HTTP request\n\n```\nDELETE https://www.googleapis.com/mirror/v1/contacts/id\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|------------------------|\n| **Path parameters** |||\n| `id` | `string` | The ID of the contact. |\n\n### Authorization\n\nThis request requires authorization with the following scope ([read more about authentication and authorization](/glass/authorization)).\n\n| Scope |\n|--------------------------------------------------|\n| `https://www.googleapis.com/auth/glass.timeline` |\n\n### Request body\n\nDo not supply a request body with this method.\n\nResponse\n--------\n\nIf successful, this method returns an empty response body.\n\nExamples\n--------\n\n**Note:** The code examples available for this method do not represent all supported programming languages (see the [client libraries page](/glass/tools-downloads/client-libraries) for a list of supported languages). \n\n### Java\n\nUses the [Java client library](/glass/tools-downloads/client-libraries). \n\n```java\nimport com.google.api.services.mirror.Mirror;\nimport com.google.api.services.mirror.model.Contact;\n\nimport java.io.IOException;\n\npublic class MyClass {\n // ...\n\n /**\n * Delete a contact for the current user.\n * \n * @param service Authorized Mirror service.\n * @param contactId ID of the Contact to delete.\n */\n public static void deleteContact(Mirror service, String contactId) {\n try {\n service.contacts().delete(contactId).execute();\n } catch (IOException e) {\n System.err.println(\"An error occurred: \" + e);\n }\n }\n\n // ...\n}\n```\n\n### .NET\n\nUses the [.NET client library](/glass/tools-downloads/client-libraries). \n\n```css+lasso\nusing System;\n\nusing Google.Apis.Mirror.v1;\n\npublic class MyClass {\n // ...\n\n /// \u003csummary\u003e\n /// Delete a contact for the current user.\n /// \u003c/summary\u003e\n /// \u003cparam name='service'\u003eAuthorized Mirror service.\u003c/param\u003e\n /// \u003cparam name='contactId'\u003eID of the Contact to delete.\u003c/param\u003e\n public static void DeleteContact(MirrorService service,\n String contactId) {\n try {\n service.Contacts.Delete(contactId).Fetch();\n } catch (Exception e) {\n Console.WriteLine(\"An error occurred: \" + e.Message);\n }\n }\n\n // ...\n}\n```\n\n### PHP\n\nUses the [PHP client library](/glass/tools-downloads/client-libraries). \n\n```php\n/**\n * Delete a contact for the current user.\n *\n * @param Google_MirrorService $service Authorized Mirror service.\n * @param string $contactId ID of the Contact to delete.\n */\nfunction deleteContact($service, $contactId) {\n try {\n $service-\u003econtacts-\u003edelete($contactId);\n } catch (Exception $e) {\n print 'An error occurred: ' . $e-\u003egetMessage();\n }\n}\n```\n\n### Python\n\nUses the [Python client library](/glass/tools-downloads/client-libraries). \n\n```python\nfrom apiclient import errors\n# ...\n\ndef delete_contact(service, contact_id):\n \"\"\"Delete a contact for the current user.\n\n Args:\n service: Authorized Mirror service.\n contact_id: ID of the Contact to delete.\n \"\"\"\n try:\n service.contacts().delete(contact_id).execute()\n except errors.HttpError, error:\n print 'An error occurred: %s' % error\n```\n\n### Ruby\n\nUses the [Ruby client library](/glass/tools-downloads/client-libraries). \n\n```ruby\n##\n# Delete a contact for the current user.\n#\n# @param [Google::APIClient] client\n# Authorized client instance.\n# @param [String] contact_id\n# ID of the contact to delete.\n# @return nil\ndef delete_contact(client, contact_id)\n mirror = client.discovered_api('mirror', 'v1')\n result = client.execute(\n :api_method =\u003e mirror.contacts.delete,\n :parameters =\u003e { 'id' =\u003e contact_id })\n if result.error?\n puts \"An error occurred: #{result.data['error']['message']}\"\n end\nend\n```\n\n### Go\n\nUses the [Go client library](/glass/tools-downloads/client-libraries). \n\n```go\nimport (\n \"code.google.com/p/google-api-go-client/mirror/v1\"\n \"fmt\"\n)\n\n// DeleteContact deletes a contact for the current user.\nfunc DeleteContact(g *mirror.Service, contactId string) error {\n err := g.Contacts.Delete(contactId).Do()\n if err != nil {\n fmt.Printf(\"An error occurred: %v\\n\", err)\n }\n return err\n}\n```\n\n### Raw HTTP\n\nDoes not use a client library. \n\n```http\nDELETE /mirror/v1/contacts/harold HTTP/1.1\nAuthorization: Bearer auth token\n```"]]