需要在请求参数中提供正确的正则表达式。以下是示例代码:
import google.auth
from google.auth.transport.requests import AuthorizedSession
# 获取授权凭据
credentials, project = google.auth.default()
# 构造API请求的Endpoint
url = 'https://firestore.googleapis.com/v1beta1/projects/{}/databases/{}/documents'.format(project, '(users|posts)')
# 创建授权会话
session = AuthorizedSession(credentials)
# 发送API请求
response = session.get(url)
# 处理API响应
if response.ok:
print(response.json())
else:
print(response.content)
上面的代码中,我们给出了一个正确的正则表达式'(users|posts)'
,用于匹配Firestore中的/users
和/posts
的文档。在构造API请求Endpoint时,我们使用了这个正则表达式来表示我们要获取所有匹配该正则表达式的文档。
上一篇:ApiService.login中出现异常:java.lang.IllegalArgumentException:NoRetrofitannotationfound.(parameter#2)