Comment #13 on issue 700 by
james.ch...@rightster.com: Doing a batched
delete of contacts always returns "If-Match or If-None-Match header or
entry etag attribute required" error
https://code.google.com/p/gdata-python-client/issues/detail?id=700
Each entry in the feed requires an etag for verification of the resource
version (
https://developers.google.com/gdata/docs/2.0/reference).
The solution is to do a query first to return the etags for your feed, then
add the respective etags to the update feed.
def make_batch_post_request(spreadsheets_client, feed):
self = spreadsheets_client
import atom
http_request = atom.http_core.HttpRequest()
http_request.add_body_part(
feed.to_string(get_xml_version(self.api_version)).replace('update', 'query'),
'application/atom+xml')
auth_token = spreadsheets_client.auth_token
uri = feed.find_edit_link()
response = self.request('POST', uri=uri, auth_token=auth_token,
http_request=http_request, desired_class=feed.__class__)
# <magic>
for index, entry in enumerate(feed.entry):
feed.entry[index].etag = response.entry[index].etag
#</magic>
http_request = atom.http_core.HttpRequest()
http_request.add_body_part(
feed.to_string(get_xml_version(self.api_version)),
'application/atom+xml')
auth_token = spreadsheets_client.auth_token
uri = feed.find_edit_link()
response = self.request('POST', uri=uri, auth_token=auth_token,
http_request=http_request, desired_class=feed.__class__)
return response