user2362956
user2362956

Reputation:

Firebase - How to write using curl?

I run sample code on firebase rest api tutorial. It says that

Data from our Firebase database can be read by issuing an HTTP GET request to an endpoint:

 curl 'https://samplechat.firebaseio-demo.com/users/jack/name.json'

A successful request will be indicated by a 200 OK HTTP status code. The response will contain the data being retrieved:

{ "first": "Jack", "last": "Sparrow" }

My result is here :

enter image description here

Now I try to write to firebase database using below command

curl -X PUT -d '{ "last": "sparrow"}' https://samplechat.firebaseio-demo.com/users/jack/name.json

The result is : enter image description here

How can I fix it?

Upvotes: 3

Views: 8750

Answers (2)

atlanteh
atlanteh

Reputation: 5835

Please try:

curl -X PUT -d "{\"name\":{\"last\": \"sparrow\"}}" https://samplechat.firebaseio-demo.com/users/jack.json

This works for me on windows.

Upvotes: 4

Zeeshan Hassan Memon
Zeeshan Hassan Memon

Reputation: 8325

Have you tried following:

curl -X PUT -d '{"name":{ "last": "sparrow"}}' https://samplechat.firebaseio-demo.com/users/jack.json

If that works you can handle "first" too.

Upvotes: 2

Related Questions