Error 401 using API Session Token in Google Apps Script


I coded a script in Google Apps Script to catch some Metabase data and write it on a Google Sheet. When I make the login using my credentials the function work and I receive the Session Token.

But using the token in the script to access my cards the error 401 Unauthenticated is shown.

var headers = {
"method": "get",
"contentType": "application/json",
"X-Metabase-Session": "22222222-cccc-4444-9999-333333333333",
"muteHttpExceptions": true

var response = UrlFetchApp.fetch(url, headers);

I test the url and session token in my local terminal using curl command and it works normally. The Google Apps Script is almost authorized and doesn't inform any error. Does someone have any idea?

Hi @Domarys
I don't know how App Script work, but the header should be Content-Type.
You might learn something from this: API POST /api/card/:card-id/query/:export-format with parameters