- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 gdata
Python 库来批量删除联系人,但我只是收到“需要 If-Match 或 If-None-Match header 或条目 etag 属性”错误。
我认为当我必须在控制台中启用 Contacts API 时问题就开始了(直到几天前还不需要?*)。
编辑:
更新和删除操作实际上都失败了。批量插入工作正常。
尝试指定 If-Match
header ,但仍然失败:
custom_headers = atom.client.CustomHeaders(**{'If-Match': '*'})
request_feed = gdata.contacts.data.ContactsFeed()
request_feed.AddDelete(entry=contact, batch_id_string='delete')
response_feed = self.gd_client.ExecuteBatch(
request_feed,
'https://www.google.com/m8/feeds/contacts/default/full/batch',
custom_headers=custom_headers
)
还创建了一个 ticket在项目页面上,但我怀疑它会在那里引起任何关注。
编辑 2:
使用带有 force=True
的 Batch
方法(它只是添加了 If-Match: *
header )是相同的结果。
response_feed = self.gd_client.Batch(
request_feed,
uri='https://www.google.com/m8/feeds/contacts/default/full/batch',
force=True
)
* 有人可以验证吗?我以前从来不需要在控制台中启用它,我的应用程序能够毫无问题地使用 Contacts API,而且我相信它以前甚至不可用。昨天看的我很吃惊。
最佳答案
正在从 Google 代码票复制答案。
基本上,您需要修补客户端的 Post
方法来稍微修改请求提要。这是一种不直接修改库源代码的方法:
def patched_post(client, entry, uri, auth_token=None, converter=None, desired_class=None, **kwargs):
if converter is None and desired_class is None:
desired_class = entry.__class__
http_request = atom.http_core.HttpRequest()
entry_string = entry.to_string(gdata.client.get_xml_version(client.api_version))
entry_string = entry_string.replace('ns1', 'gd') # where the magic happens
http_request.add_body_part(
entry_string,
'application/atom+xml')
return client.request(method='POST', uri=uri, auth_token=auth_token,
http_request=http_request, converter=converter,
desired_class=desired_class, **kwargs)
# when it comes time to do a batched delete/update,
# instead of calling client.ExecuteBatch, instead directly call patched_post
patched_post(client_instance, entry_feed, 'https://www.google.com/m8/feeds/contacts/default/full/batch')
关于python - 批量删除联系人报 "If-Match or If-None-Match header or entry etag attribute required"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23576729/
我是 Java 新手,我遇到了这个我无法解决的问题。我继承了这个项目,并且我的 scriptlet 之一中有以下代码: DefaultLogger.logMessage("DEBUG path: "+
在做web应用的自动化测试时,定位元素是必不可少的,这个过程经常会碰到定位不到元素的情况(报selenium.common.exceptions.NoSuchElementException),一般
我之前已经这样做过,但令我惊讶的是 CListCtrl 不会以颜色显示文本。我在对话框上有 ListView 控件。我正在使用 VS2010,是否还缺少其他东西? void CGameView::On
我正在尝试计算 4 个表中每个学生的 GPA: Student(STUDENT_ID, STUDENT_LNAME, STUDENT_FNAME, MAJOR) Course(COURSE_NO, C
当我在 windows 和 mac 上使用 jasper 报告时它工作正常,当我将我的应用程序部署到 linux 机器 并尝试生成它抛出的报告时 net.sf.jasperreports.engine
我正在构建 iOS 应用并尝试实现应用内购买(非消费品)。 所有 bundle ID 等都已设置并正常工作,当我获取 Apple Store 服务器时,我可以看到我的产品有效。但是,在测试时,我在 p
我正在尝试使用非固定字符数组读取用户输入,但当我在键盘上输入内容时它只是软崩溃(没有崩溃窗口)。当我在在线 C 编译器上运行它时,它说 Segmentation fault (core dumped)
事实: 无根 podman 非常适合 uid 1480 无根 podman 为 uid 2088 失败 中央操作系统 7 内核 3.10.0-1062.1.2.el7.x86_64 podman 版本
根据 homebrew-brew 官方的解释得知,MongoDB 不再是开源的了,并且已经从 Homebrew中移除 #43770 正是由于 MongoDB 的商业化不太理想,所以它选择了闭源。所
我用命令禁用collectstatic heroku config:set DISABLE_COLLECTSTATIC=1 成功将我的项目推送到 Heroku 后,手动 collectstatic 如
代码如下: public class TryStuffOutHere { public static void main(String[] args) {
我已经设置了我的 redis 服务器,以便 CONFIG GET dir --> "/var/lib/redis" 和 CONFIG GET dbfilename --> "redis.rdb". 但
我是一名优秀的程序员,十分优秀!