【发布时间】:2021-08-21 10:21:07
【问题描述】:
下面是我的代码,我正在尝试使用 Firebase Firestore Rest API 发送发布请求。它可以工作,但它会生成一个随机 ref id 令牌,将其链接到我发送的帖子数据(字段),这使得关联起来很困难。
我希望能够将我的帖子数据与自定义 id 令牌相关联。
final String customIdToken9 = 'customIdToken9'
String url = "https://firestore.googleapis.com/v1/projects/myAppId/databases/(default)/documents/customers/$customIdToken9"
const _body = {
"fields": {
"androidNotificationToken": {
"nullValue": null
},
"fullname": {
"stringValue": "Custom"
},
"uid": {
"stringValue": "$customIdToken9"
},
"admin": {
"stringValue": ""
},
"email": {
"stringValue": "customer1@gmail.com"
},
"photo": {
"stringValue": ""
},
"coverPhoto": {
"stringValue": ""
},
"bio": {
"stringValue": ""
},
"role": {
"stringValue": "user"
},
"mobile": {
"stringValue": "092222"
}
}
}
http.post(url, body = _body);
当我在上面运行这段代码时,它会返回
{
"error": {
"code": 400,
"message": "Document parent name \"projects/MyAppId/databases/(default)/documents/customers\" lacks \"/\" at index 59.",
"status": "INVALID_ARGUMENT"
}
}
如果我删除 customTokenId9,它可以工作,但它会生成一个我不想要的随机令牌 ID
String url = "https://firestore.googleapis.com/v1/projects/myAppId/databases/(default)/documents/customers/"
http.post(url, body = _body);
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore http-post