title: Firebase REST API POST request fails with error: "Invalid data; couldn't parse JSON object, array, or value..."
body: <p>I'm trying to use Firebase REST API to save stuff into my data store. I tried with jQuery and vanilla JS XHR. However, both give the same error. 403 Bad Request and this response:</p>
  
  <blockquote>
    <p>Invalid data; couldn't parse JSON object, array, or value. Perhaps you're using invalid characters in your key names.</p>
  </blockquote>
  
  <p>Here is my example JSON, I'm trying to save:</p>
  
  <pre><code>{
      "date": "2pm", 
      "name": "John"
  }
  </code></pre>
  
  <p>Here is the example ajax request:</p>
  
  <pre><code>jQuery.ajax({
      accept: "application/json",
      type: 'POST',
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      url: "https://something.firebaseio.com/endpointnode.json",
      data: {
          "name": "John", 
          "date": "2pm"        
      },
  });
  </code></pre>
  
  <p>Response of the request:</p>
  
  <pre><code>{
      "error" : "Invalid data; couldn't parse JSON object, array, or value. Perhaps you're using invalid characters in your key names."
  }
  </code></pre>
  
  <p>As you can see, there is no special chars or anything. It should just work.</p>
  
  <p>It works fine with CURL and Httpie. I tried to check <code>-v</code> option in Httpie for details. I put all of the headers as Httpie does. Nothing helped.
  By the way, my environment is writable so there should not be any permission issue.</p>
  
  <p>Any idea how to achieve this?</p>
  
  <p>Thanks.</p>