mardi 1 janvier 2019

Update single field on Firestore database (cloud) with simple https request

I'm currently using Swift (macOS) & that doesn't matter.

I can get my database data with this simple get request from Firestore

https://firestore.googleapis.com/v1beta1/projects/MY_PROJECT_NAME/databases/(default)/documents/" + "User_email" + "?pageSize=100&pageToken=" + "NextPage_Id"

Now I want to update one single filed on the database & I don't know how.

The Firebase api guide is too complicated for me & I don't understand it.

I found this get request url:

https://firestore.googleapis.com/v1beta1/projects/{projectId}/databases/{databaseId}/documents/{document_path}?updateMask.fieldPaths=status&updateMask.fieldPaths=title

But when I try it, it gives me this error:

 {
"details" : [
  {
    "fieldViolations" : [
      {
        "description" : "Invalid JSON payload received. Unknown name \"updateMask.fieldPaths\": Cannot bind query parameter. Field 'updateMask' could not be found in request message."
      }
    ],
    "@type" : "type.googleapis.com\/google.rpc.BadRequest"
  }
],
"code" : 400,
"message" : "Invalid JSON payload received. Unknown name \"updateMask.fieldPaths\": Cannot bind query parameter. Field 'updateMask' could not be found in request message.",


  "status" : "INVALID_ARGUMENT"
  }
}

I Use above url like this:

https://firestore.googleapis.com/v1beta1/projects/MY_PROJECT_NAME/databases/(default)/documents/" + User_email + "/MY_COLLECTION_ID/?updateMask.fieldPaths=name&updateMask.fieldPaths=aaaa

Where did I do wrong?




Aucun commentaire:

Enregistrer un commentaire