title: Firebase functions not registering document which definitely exists
body: <p>I am trying to create a firebase function HTTP endpoint which will allow the posting of a user ID and return if the user exists in the database or not.</p>
  <p><strong>Structure of my database:</strong></p>
  <p>User ID = document ID in users collection</p>
  <p><a href="https://i.stack.imgur.com/1J8Xk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1J8Xk.png" alt="enter image description here" /></a></p>
  <p><strong>What I have tried</strong></p>
  <p>I created the following code, which would always return &quot;User does not exist!&quot; even when providing an existing user ID:</p>
  <pre class="lang-js prettyprint-override"><code>const functions = require(&quot;firebase-functions&quot;);
  const admin = require(&quot;firebase-admin&quot;);
  admin.initializeApp();
  
  exports.userExists = functions.https.onRequest((request, response) =&gt; {
    if (request.method !== &quot;POST&quot;) {
      return response.status(400).send(&quot;Please send a POST request&quot;);
    } else {
      const userRef = admin.firestore().collection(&quot;users&quot;).doc(request.body.userID);
      userRef.get().then((doc) =&gt; {
        functions.logger.info(doc.data());
        if (doc.exists) {
          response.status(200).send(&quot;User Exists!&quot;);
        } else {
          response.status(200).send(&quot;User does not exist!&quot;);
        }
      }).catch((err) =&gt; {
        response.status(500).send(err);
      });
    }
  });
  </code></pre>
  <p>I even tried hardcoding the user ID into the function, with no luck either:</p>
  <pre class="lang-js prettyprint-override"><code>const functions = require(&quot;firebase-functions&quot;);
  const admin = require(&quot;firebase-admin&quot;);
  admin.initializeApp();
  
  exports.userExists = functions.https.onRequest((request, response) =&gt; {
    if (request.method !== &quot;POST&quot;) {
      return response.status(400).send(&quot;Please send a POST request&quot;);
    } else {
      const userRef = admin.firestore().collection(&quot;users&quot;).doc(&quot;DGxyfSrLnzLTp3Adzmm7VL6sOZz2&quot;);
      userRef.get().then((doc) =&gt; {
        functions.logger.info(doc.data());
        if (doc.exists) {
          response.status(200).send(&quot;User Exists!&quot;);
        } else {
          response.status(200).send(&quot;User does not exist!&quot;);
        }
      }).catch((err) =&gt; {
        response.status(500).send(err);
      });
    }
  });
  </code></pre>
  <p><strong>Code for calling the function, and output:</strong></p>
  <pre class="lang-py prettyprint-override"><code>import requests
  
  data = { &quot;userID&quot;: &quot;DGxyfSrLnzLTp3Adzmm7VL6sOZz2&quot; }
  r = requests.post(&quot;https://{domain_hidden}.cloudfunctions.net/userExists&quot;, data)
  
  print(data[&quot;userID&quot;])
  print(r.status_code)
  print(r.headers)
  print(r.text)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Z4TrH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z4TrH.png" alt="enter image description here" /></a></p>
  <p>I am completely stumped and can only assume now that I am missing something simple, so reaching out here for advice. Thanks.</p>
  <p><strong>EDIT -- as requested the code used to create new users</strong></p>
  <p>I see now as suggested by @Dharmaraj that the user's IDs are in Italics, meaning they do not actually exist. I actually created the user Docs by creating docs in a user sub collection called plants. The code is as follows:</p>
  <pre class="lang-js prettyprint-override"><code>const plant = await addDoc(collection(firestore, &quot;users&quot;, user.uid, &quot;plants&quot;), {
    name: plantName
  });
  </code></pre>
  <p>Do I need to explicitly create a user document before creating items in subcollections?</p>