1
votes

This is what I can do:

  1. Insert data into FireBase with Postman
  2. Query data From FireBase with Postman
  3. Query Data from FireStore with Postman

Example: Get From FireStore:
https://firestore.googleapis.com/v1beta1/projects/myProjectID/databases/(default)/documents/alerts (this works)

Post to FireBase: https://myProjectID.firebaseio.com/alerts.json (plus the raw json) - this works on firebase but not firestore

What I cannot do is create a new record in FireStore from Postman. This is what I found..

https://firestore.googleapis.com/v1beta1/{database=projects//databases/}/documents:write

This does not work for me. I would like to do it from Postman. My database is called Alerts. Any help will be greatly appreciated.

1

1 Answers

4
votes

for create document in firestore, you can follow official guide :

for example, in 3 steps:

  1. URL Post

    https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents/your-collection-name?key={Your Web API Key}

for Web API Key, you can find it in Project Setting (Gear Icon) in Firebase console

  1. Setting Database Rules in firebase console. Allow write and read to rule! (for now, idk to setting auth from postman)

    rules_version = '2'; service cloud.firestore { match /databases/{database}/documents {

     match /{document=**} {
       // allow read, write: if request.auth != null;
    
       allow read;
       allow write;
     }
    

    } }

  2. Json Document

    { "fields": { "username": { "stringValue": "John Doe" }, "total_like": { "integerValue": "100" } }, "createTime": "2020-05-13T23:00:29.0Z", "updateTime": "2020-05-13T23:00:29.0Z" }

OK, done just send it from postman!