title: POST vs. GET request differences in Google Analytics API Version 4
body: <p>Google Analytics v4 API now uses POST requests instead of GET request. And there are no good javascript examples out there yet for me to follow. I'm getting empty object Object { }, but I'm sure that data is there and ViewID is correct!</p>
  
  <p>Any advice on what I am doing wrong? or are there any fully working example that I can follow? Thanks.</p>
  
  <pre><code>requestData = function () {
  var url = "https://analyticsreporting.googleapis.com/v4/reports:batchGet?";
  
  var params = {
      "reportRequests":[{
          "viewId":"12345678",
          "dateRanges":[{
              "startDate":"yesterday",
              "endDate":"today"
          }],
          "metrics":[{
            "expression":"ga:users"
          }],
          "dimensions": [{
            "name":"ga:pagePath"
          }]
      }]
  }
  
  $.ajax({       
      url: url,
      type: "POST",
      data: params,
      dataType: "json",
      success: function(results) {
          console.log(results)
      },
      error: function(xhr, ajaxOptions, thrownError) {
          alert('failed');
          alert(xhr.status);
          alert(thrownError);
      }
  });
  </code></pre>