How to Create google sheet and add data?

Hi all,
i’m able to append data to an existing sheet but
I don’t understand how to create a google sheet and add some row.
I use google create for the spreadsheet, it’s OK
retrieve data from postgres, it’s ok
but how to create column header key to append data in this new spreadsheet ??

I miss something somewhere ?

Thanks

{
  "nodes": [
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "spreadsheet",
        "title": "testn8n",
        "sheetsUi": {
          "sheetValues": [
            {
              "propertiesUi": {
                "title": "feuillfeuill"
              }
            }
          ]
        },
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        300,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "n8n project"
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "append",
        "sheetId": "={{$node[\"Google Sheets\"].json[\"spreadsheetId\"]}}",
        "options": {
          "valueInputMode": "RAW"
        }
      },
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        720,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "n8n project"
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "select id, filter_name, user_email\nfrom product_user_filter"
      },
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        510,
        300
      ],
      "credentials": {
        "postgres": "postgres"
      }
    }
  ],
  "connections": {
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Welcome to the community @Chris_Doudet!

Yes, there is currently sadly no easy way to do that yet. You would have to go through RAW data to do it.

In the following example, you can define the columns in the Set node, comma-separated. Be however aware that this overwrites the data of the whole sheet. Probably not a problem in your case, as it is empty, but still wanted to have it mentioned.

{
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "rows",
              "value": "id,filter_name,user_email"
            }
          ]
        },
        "options": {}
      },
      "name": "Define rows",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      data: [ $json.rows.split(',') ]\n    }\n  }\n];\n"
      },
      "name": "Convert",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "update",
        "sheetId": "1Wgf4bbjPwL5XzhBVm5mKV-DYr3FjzqIS16rcD_ykzpY",
        "rawData": true,
        "options": {}
      },
      "name": "Google Sheets16",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        900,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": ""
      }
    }
  ],
  "connections": {
    "Define rows": {
      "main": [
        [
          {
            "node": "Convert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert": {
      "main": [
        [
          {
            "node": "Google Sheets16",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Perfect,
thanks

You are welcome. Have fun!