drwkqwa82140 2018-04-17 12:20 采纳率: 0%
浏览 33

Google Drive API V3如何正确转义查询参数?

Given: working access to Google Drive with some Folders with Space in Name

Problem: The query:

name='07 Dirname' and mimeType='application/vnd.google-apps.folder' and '0B22uLx7BCvv9T0FWRmNaREY4VEE' in parents and trashed=false

does not work over the API, but does if the dir is without space in it. The query does work however if you run it from the API-Explorer which provides as hint: This parameter was URL encoded.

However when I encode the name field with url.QueryEscape or url.PathEscape the folder can not be found. As far as I understand it its not necessary to encode the whole query, just the param, but how?

Thx.

  • 写回答

2条回答 默认 最新

  • drn9573 2018-04-17 12:35
    关注

    The query needs to be double encoded to work, so call url.QueryEscape first on the search given above and then again on the query string.

    If you look at the API Explorer with Chrome devtools, you will see the double encoded values despite the misleading display on the page itself.

    e.g. something like https://content.googleapis.com/drive/v3/files?q=name%3D%2707+Dirname%27+and+mimeType%3D%27application%2Fvnd.google-apps.folder%27+and+%270B22uLx7BCvv9T0FWRmNaREY4VEE%27+in+parents+and+trashed%3Dfalse&key={APIKEY}

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向