Realizar operações em lote
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Se você estiver realizando várias operações, o tempo necessário para enviar e receber
todas essas mensagens HTTP pode deixar o app lento e sem resposta. Com as solicitações em lote, é possível fazer com que o servidor realize várias operações com uma única solicitação HTTP. A ideia básica é criar um feed de contatos e adicionar uma entrada para cada operação que você quer realizar.
As solicitações em lote são limitadas a 100 operações por vez. Confira mais informações sobre operações em lote em Processamento em lote no protocolo de dados do Google.
As mudanças podem levar até 24 horas para serem exibidas no preenchimento automático do endereço de e-mail e no gerenciador de contatos.
O exemplo de código abaixo mostra uma solicitação em lote que cria dois contatos
compartilhados. No entanto, você também pode usar uma solicitação em lote para consultar, atualizar e excluir
contatos. As entradas de atualização e exclusão exigem um link de edição para que a
concorrência otimista
funcione.
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:gContact='http://schemas.google.com/contact/2008'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:batch='http://schemas.google.com/gdata/batch'>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/g/2008#contact' />
<entry>
<batch:id>1</batch:id>
<batch:operation type='insert' />
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/g/2008#contact'/>
<gd:name>
<gd:givenName>FIRST_NAME</gd:fullName>
<gd:familyName>LAST_NAME</gd:fullName>
</gd:name>
<gd:email rel='http://schemas.google.com/g/2005#home'
address='EMAIL_ADDRESS' primary='true'/>
</entry>
<entry>
<batch:id>2</batch:id>
<batch:operation type='insert' />
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/g/2008#contact'/>
<gd:name>
<gd:givenName>FIRST_NAME</gd:fullName>
<gd:familyName>LAST_NAME</gd:fullName>
</gd:name>
<gd:email rel='http://schemas.google.com/g/2005#home'
address='EMAIL_ADDRESS'
primary='true'/>
</entry>
</feed>
Substitua:
FIRST_NAME
: o nome do contato compartilhado, por
exemplo, Alex.
LAST_NAME
: o sobrenome do contato
compartilhado, por exemplo, Kim.
EMAIL_ADDRESS
: o endereço de e-mail
preferencial do contato compartilhado, por exemplo, alk@gmail.com.
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-03-25 UTC.
[null,null,["Última atualização 2025-03-25 UTC."],[],[],null,["# Perform batch operations\n\nIf you're performing several operations, the time it takes to send and receive\nall those HTTP messages can make your app slow and unresponsive. With batch\nrequests, you can have the server perform multiple operations with a single HTTP\nrequest. The basic idea is that you create a contacts feed and add an entry for\neach operation that you want to perform.\n\nBatch requests are limited to 100 operations at a time. You can find more\ninformation about batch operations in\n[Batch Processing in the Google Data Protocol](https://developers.google.com/gdata/docs/batch).\nChanges can take up to 24 hours to be reflected in the email address\nautocomplete and the contact manager.\n\nThe following code sample shows a batch request that creates 2 shared\ncontacts; however, you can also use a batch request to query, update, and delete\ncontacts. The update and delete entries require an edit link for\n[optimistic concurrency](https://developers.google.com/gdata/docs/1.0/reference#Optimistic-concurrency)\nto work. \n\n```xml\n\u003c?xml version='1.0' encoding='UTF-8'?\u003e\n\u003cfeed xmlns='http://www.w3.org/2005/Atom'\n xmlns:gContact='http://schemas.google.com/contact/2008'\n xmlns:gd='http://schemas.google.com/g/2005'\n xmlns:batch='http://schemas.google.com/gdata/batch'\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/g/2008#contact' /\u003e\n \u003centry\u003e\n \u003cbatch:id\u003e1\u003c/batch:id\u003e\n \u003cbatch:operation type='insert' /\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/g/2008#contact'/\u003e\n \u003cgd:name\u003e\n \u003cgd:givenName\u003eFIRST_NAME\u003c/gd:fullName\u003e\n \u003cgd:familyName\u003eLAST_NAME\u003c/gd:fullName\u003e\n \u003c/gd:name\u003e\n \u003cgd:email rel='http://schemas.google.com/g/2005#home'\n address='EMAIL_ADDRESS' primary='true'/\u003e\n \u003c/entry\u003e\n \u003centry\u003e\n \u003cbatch:id\u003e2\u003c/batch:id\u003e\n \u003cbatch:operation type='insert' /\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/g/2008#contact'/\u003e\n \u003cgd:name\u003e\n \u003cgd:givenName\u003eFIRST_NAME\u003c/gd:fullName\u003e\n \u003cgd:familyName\u003eLAST_NAME\u003c/gd:fullName\u003e\n \u003c/gd:name\u003e\n \u003cgd:email rel='http://schemas.google.com/g/2005#home'\n address='EMAIL_ADDRESS'\n primary='true'/\u003e\n \u003c/entry\u003e\n\u003c/feed\u003e\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFIRST_NAME\u003c/var\u003e: First name of the shared contact---for example, Alex.\n- \u003cvar translate=\"no\"\u003eLAST_NAME\u003c/var\u003e: The last name of the shared contact---for example, Kim.\n- \u003cvar translate=\"no\"\u003eEMAIL_ADDRESS\u003c/var\u003e: The preferred email address of the shared contact---for example, alk@gmail.com."]]