'google sheets api v4 Append row after specific row or move row to specific position

Is it possible to append a row after a specific row/range?
For example, I have a spreadsheet with 5 rows where in column A is written for row one "1", for row two "2" but in row three "4" and so on till row five "6".

Now I want to append a row to this table and I currently use this function:

let values = [
  [
    // Cell values ...
  ],
  // Additional rows ...
];
let resource = {
  values,
};
this.sheetsService.spreadsheets.values.append({
  spreadsheetId,
  range,
  valueInputOption,
  resource,
}, (err, result) => {
  if (err) {
    // Handle error.
    console.log(err);
  } else {
    console.log(`${result.updates.updatedCells} cells appended.`);
  }
});

The row I want to append has in column A a "3" and I want the row appended after Row two.

But when I set the range to "A2:C2" it will only append it where the first empty row is; after row five.

Is there a way to append rows inbetween rows? If not, is it possible to move the appended row from bottom to the desired position?

PS: I don't want to order the rows by alphabet or number. I just use numbers to show what I mean.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source