title: How to save data to Google SpreadSheet using Unity 3D
body: <p>Previously, I was able to send data from a HTML Form to Google Form (Responses Spreadsheet) using <code>ajax</code>. Here's the code.</p>
  
  <p><strong>Ajax Code</strong></p>
  
  <pre><code>function postContactToGoogle() {
   var email = $('#emailtosubscribe').val();
   $.ajax({
    url: "https://docs.google.com/forms/d/e/[key]/formResponse",
    data: {
     "entry_1064445353": email
    },
    type: "POST",
    dataType: "xml",
    statusCode: {
     0: function() {
      window.location.reload();
     },
     200: function() {
      window.location.reload();
     }
    }
   });
  }
  </code></pre>
  
  <p>Now, I am trying to do the same in Unity using <code>UnityWebRequest</code>. Here's my code</p>
  
  <p><strong>Unity Code</strong></p>
  
  <pre><code>public class SendToGoogle : MonoBehaviour {
      public GameObject email;
  
      private string Email;
  
      [SerializeField]
      private string BASE_URL = "https://docs.google.com/forms/d/e/[key]/formResponse";
  
      IEnumerator Post(string json) {
          byte[] bytes = System.Text.Encoding.ASCII.GetBytes(json);
  
          using (UnityWebRequest www = new UnityWebRequest(BASE_URL, UnityWebRequest.kHttpVerbPOST)) {
              UploadHandlerRaw uH = new UploadHandlerRaw(bytes);
              DownloadHandlerBuffer dH = new DownloadHandlerBuffer();
              www.uploadHandler = uH;
              www.downloadHandler = dH;
              www.SetRequestHeader("Content-Type", "application/json");
              yield return www.Send();
  
              if (www.isError) {
                  Debug.Log(www.error);
              } else {
                  Debug.Log(www.ToString());
                  Debug.Log(www.downloadHandler.text);
              }
          }
      }
  
      public void Subscribe() {
          Email = email.GetComponent&lt;InputField&gt;().text;
          var n = new JSONObject();
          n["entry_1064445353"] = Email;
          string json = n.ToString();
          Debug.Log(Email);
          StartCoroutine(Post(json));
      }
  }
  </code></pre>
  
  <p>Now when I try to submit email from the Scene, time stamp is created in the spreadsheet but the email is not saved. I am doubtful on  <code>www.SetRequestHeader("Content-Type", "application/json");</code>, as in <code>ajax</code> I am using <code>xml</code> as <code>datatype</code> with <code>dataType: "xml"</code>. </p>
  
  <p>Moreover, I also tried sending just <code>string</code> without changing it to <code>JSONObject</code> and changing <code>Content-Type</code> on <code>SetRequestHeader</code> to <code>xml</code>.</p>