Logs from POST not showing?

36 views
Skip to first unread message

Domon

unread,
Oct 27, 2025, 5:09:48 AM (10 days ago) Oct 27
to Google Apps Script Community
I'm using the reserved doPost function to receive a CSV file. However, when i use the method e.postData.contents and log it, it doesn't seem to log anything. Actually, it is more like appscript malfunctions, as usually it will show " No logs are available for this execution". Here is what i mean:
Screenshot 2025-10-27 022658.png
As you can see, there is no downwards carrot symbol like there would be for all executions. Clicking on the log itself results in no changes.

Web Dev

unread,
Oct 27, 2025, 1:20:48 PM (10 days ago) Oct 27
to Google Apps Script Community
are you sure you're hitting the correct url for your latest deployment? Make a test deployment and test against that. Also, see the entire 'e' object with Logger.log(JSON.stringify(e));

Tim Dobson

unread,
Oct 29, 2025, 7:35:01 PM (7 days ago) Oct 29
to google-apps-sc...@googlegroups.com
I didn't realise it was possible at all to *ever* see a log for a doPost. I presume from this post that it is - it just has to be a test deployment not a production one?

Sorry for the stupid question, if this turns out to be true (feel free to link me to docs) I will have a really good day as this will make my life easier. 

Cheers

Tim

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/2aef09d1-1e60-468e-ba74-41308277f1c8n%40googlegroups.com.

Kildere S Irineu

unread,
Oct 30, 2025, 9:40:15 AM (7 days ago) Oct 30
to google-apps-sc...@googlegroups.com

🧩 Problema:

Você usa a função doPost(e) para receber um arquivo CSV via HTTP POST, mas:

  • e.postData.contents parece vazio.

  • Logs não aparecem na execução no Apps Script.

  • Não há o “▶️” para expandir os detalhes da execução, como mostrado na IDE.


🧠 Causa provável:

1. doPost só registra logs se for invocado por test deployments ou testes manuais com testoPost()

  • Invocações via curl, webhook, cliente externo usando a URL publicada não aparecem com logs no Editor de Script.

  • Isso ocorre porque essas execuções são “headless”: são tratadas como “serviços públicos” e não associam a execução ao seu usuário na IDE.

2. Você pode ver que a função executou no painel "Executions", mas:

  • Logs (Logger.log) não aparecem.

  • console.log também não mostra nada no Apps Script Dashboard.


Soluções práticas

✔️ Opção 1: Usar test doPost() manual

Você pode simular o envio localmente no próprio Apps Script com uma função auxiliar:

function testDoPost() { const fakeEvent = { postData: { contents: 'name,email\nJoão,jo...@email.com', type: 'text/csv' } }; const result = doPost(fakeEvent); Logger.log(result); }

Isso permite testar e ver Logger.log() normalmente.


✔️ Opção 2: Armazenar logs dentro da planilha ou Drive

Como alternativa para obter os logs de execuções públicas:

function logToSheet(message) { const sheet = SpreadsheetApp.openById('SEU_ID_PLANILHA_LOG').getSheetByName('Logs'); sheet.appendRow([new Date(), message]); }

E use dentro do doPost(e):

logToSheet('Conteúdo recebido: ' + e.postData.contents);

✔️ Opção 3: Ativar Stackdriver Logs (monitoramento via Cloud)

  1. Vá ao Google Cloud Console > Logging.

  2. Acesse os logs de execução por lá — são mais detalhados.

  3. Mas para isso, o projeto Apps Script precisa estar vinculado a um projeto do GCP.


🧪 Dica de Debug extra

Logar o objeto e inteiro é muito útil:

logToSheet(JSON.stringify(e));

Use para confirmar se o conteúdo está chegando como base64, multipart/form-data etc.


📚 Referências úteis:



Reply all
Reply to author
Forward
0 new messages