'Can't add document from Firestore API. Error 400 Resource name ... lacks \"projects\" at index 0

I try to add one document from Firestore API Explorer.

This is the data i try to insert:

POST https://firestore.googleapis.com/v1/projects/myProjetID/databases/(default)/documents/myCollection/2019/04?documentId=10&key={YOUR_API_KEY}

{
 "fields": {
  "field0": {
   "referenceValue": "ref0"
  }
 }
}

I'm having this error:

cache-control:  private
content-encoding:  gzip
content-length:  143
content-type:  application/json; charset=UTF-8
date:  Mon, 08 Apr 2019 09:24:09 GMT
server:  ESF
vary:  Origin, X-Origin, Referer

{
 "error": {
  "code": 400,
  "message": "Resource name \"ref0\" lacks \"projects\" at index 0.",
  "status": "INVALID_ARGUMENT"
 }
}

I don't know what's wrong.



Solution 1:[1]

For me I had to execute the export statement of FIRESTORE_EMULATOR_HOST variable printed when I started the firestore emulator.

For eg,

export FIRESTORE_EMULATOR_HOST=[::1]:8647

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kannan Ramamoorthy