title: How to correctly set values from JSON API response into Google Spreadsheet
body: <p>I am trying to get data into my google sheets from this API, I want to set the values each one in one row and if possible split them in columns.</p>
  <p>I tried this code below but what I get is that the script set the values each one in one column and whithout spliting the data.</p>
  <p><a href="https://i.stack.imgur.com/cvhiq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cvhiq.png" alt="spreadsheet screenshot" /></a></p>
  <pre><code>function myFunction() {
    
  }
  
  var urlRequest = 'https://www.presupuestoabierto.gob.ar/api/v1/credito?format=json'
        
  var body = {
        &quot;title&quot;: &quot;Credito devengado&quot;,
        &quot;ejercicios&quot;:[2020],
        &quot;columns&quot;: [
         &quot;impacto_presupuestario_mes&quot;,
          &quot;ejercicio_presupuestario&quot;,
          &quot;jurisdiccion_id&quot;,
          &quot;jurisdiccion_desc&quot;,
          &quot;servicio_desc&quot;,
          &quot;inciso_id&quot;,
          &quot;principal_desc&quot;,
          &quot;credito_devengado&quot;,
          &quot;ultima_actualizacion_fecha&quot;],
        &quot;filters&quot;: [
          {
                      &quot;column&quot;: &quot;inciso_id&quot;,
                      &quot;operator&quot;: &quot;equal&quot;,
                      &quot;value&quot;: &quot;1&quot;
                  },
                  {
                      &quot;column&quot;: &quot;jurisdiccion_id&quot;,
                      &quot;operator&quot;: &quot;equal&quot;,
                      &quot;value&quot;: &quot;30&quot;
                  }
              ]
      }
  
  
  var options = {
      muteHttpExceptions: true,
      method: 'POST',
      headers: {Authorization:'a......e','Content-Type':'application/json'},
      payload: JSON.stringify(body)
  }
  
  var response = UrlFetchApp.fetch(urlRequest, options);
  var json = response.getContentText();
  var dataAll = JSON.parse(json);
   
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  var sheet = ss.getActiveSheet();
  
  
  // I modified below.
  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>