Ger*_*tha 5 firebase firebase-realtime-database google-cloud-firestore
这是我在Firestore数据库中创建新文档时执行的REST API调用
POST https://firestore.googleapis.com/v1beta1/projects/[xxx]/数据库/(默认)/ documents /项目
这是我添加到post方法主体中的有效负载:
{
“ name”:“项目/ [xxx] /数据库/(默认)/ documents / items / 6001156905205”,
“字段”:{
“名称”: {
“ stringValue”:“ Freshpak Rooibos Tea 80Pk”
},
“说明”:{
“ stringValue”:“享受一杯Freshpak Rooibos您的No 1 Rooibos茶。
}
},
“ createTime”:“ 2018-02-21T14:20:55.753234Z”,
“ updateTime”:“ 2018-02-21T14:20:55.753234Z”
}
我收到以下错误消息:
{
“错误”:{
“代码”:400,
“ message”:“不能设置document.name”,
“状态”:“ INVALID_ARGUMENT”
}
}
当我从有效负载中删除“ name”属性时,它会在firebase中创建记录,但随后会自动生成文档ID。我希望ID为6001156905205。
难道我做错了什么?
谢谢格特
You need to specify the document ID that you want to use, as a query parameter, as detailed here. The createTime and updateTime are output only, so they will automatically be set by Cloud Firestore.
POST https://firestore.googleapis.com/v1beta1/projects/[xxx]/databases/(default)/documents/items?documentId=6001156905205
Run Code Online (Sandbox Code Playgroud)
{
"fields": {
"Name": {
"stringValue": "Freshpak Rooibos Tea 80Pk"
},
"Description": {
"stringValue": "Enjoy a cup of Freshpak Rooibos your no 1 Rooibos tea.
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2314 次 |
| 最近记录: |