使用REST将数据保存到Firebase [英] Saving data to Firebase with REST
问题描述
我使用Firebase使用REST API存储应用程序令牌。
这是数据结构我正在使用:
This is the data structure I'm using:
这是添加新应用程序后的数据结构。
这是我使用的命令。
curl -X POST -d "{\"3ba7792jae16328\":{\"name\":\"Test 2\"}}" \ https://xxx.firebaseio.com/apps.json
我不想要POST请求添加到我的数据结构的唯一ID。我已经尝试过一个PUT请求,但它覆盖了apps节点内的所有数据。无论如何这是我尝试的PUT命令。
I don't want the unique ID that the POST request adds to my data structure. I already tried with a PUT request but it override all the data inside the "apps" node. Anyways this is the PUT command I tried.
curl -X POST -d "{\"3ba7792jae16328\":{\"name\":\"Test 2\"}}" \ https://xxx.firebaseio.com/apps.json
是否有其他方法可以添加数据并保留我的结构?
自动生成POST令牌作为我自己的应用程序令牌不是有效的答案)
(Use the auto generated POST tokens as my own application tokens is not a valid answer)
推荐答案
>到网址:
You should put your self-generated ID into the URL:
curl -X POST -d "{\":{\"name\":\"Test 2\"}" \ https://xxx.firebaseio.com/apps/3ba7792jae16328.json
Firebase始终会覆盖(除非您使用 PATCH
)您指定的URL处的整个节点。因此,请务必指定您要覆盖数据的级别。
Firebase always overwrites (unless you use PATCH
) the entire node at the URL you indicate. So it's important that you specify the URL up to the level that you want to overwrite data.
这篇关于使用REST将数据保存到Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!