title: Scrape data from website using Google apps script and paste to Google sheet
body: <p>I adapted some code that I found that retrieves data from a url (<a href="https://www.lme.com/api/trading-data/day-delayed?datasourceId=9ca4cc7d-4812-479f-8068-23a9053921c1" rel="nofollow noreferrer">https://www.lme.com/api/trading-data/day-delayed?datasourceId=9ca4cc7d-4812-479f-8068-23a9053921c1</a>) in json format and pastes it to a Google Sheet.</p>
  <p>It seems to be retrieving all the headers, but it is missing the data for all the contracts and prices (you can see it if you open the url). I am wondering what I am doing wrong. The code is below:</p>
  <pre><code>function getJSON() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheets = ss.getSheets();
    var sheet = ss.getActiveSheet();
    var url=&quot;https://www.lme.com/api/trading-data/day-delayed?datasourceId=9ca4cc7d-4812-479f-8068-23a9053921c1&quot;; // JSON URL
    var response = UrlFetchApp.fetch(url);
    var dataAll = JSON.parse(response.getContentText());
    var rows = [Object.keys(dataAll)]; // Retrieve headers.
    var temp = [];
    for (var i = 0; i &lt; rows[0].length; i++) {
      temp.push(dataAll[rows[0][i]]); // Retrieve values.
    }
    rows.push(temp);
    sheet.getRange(1,1,rows.length,rows[0].length).setValues(rows); // Put values to Spreadsheet.
  }
  </code></pre>