I am still having no success getting the API to work. I can’t even get the “Try It” feature to work.
This is what I am doing:
I start with the “Get base token with API token” endpoint. I enter my API token into the Bearer field & click the Try It button. I get the following response:
{
"app_name": "app.ab",
"access_token": "REMOVED TOKEN",
"dtable_uuid": "REMOVED UUID",
"dtable_server": "https://cloud.seatable.io/dtable-server/",
"dtable_socket": "https://cloud.seatable.io/",
"dtable_db": "https://cloud.seatable.io/dtable-db/",
"workspace_id": 63025,
"dtable_name": "Corsi di Laurea",
"use_api_gateway": true
}
==============================
I then go to the “List Rows” endpoint. Again I enter my API token in the Bearer field. I enter the dtable_uuid token from above into the base_uuid field & my table name into the table_name field. These are the only 2 required fields. When I click the Try It button I get a response of “invalid token”, as below:
{
"error_message": "invalid token"
}
const options = {
method: 'GET',
headers: {
accept: 'application/json',
authorization: 'Bearer **REMOVED**' //personal token
}
};
const API_URL = 'https://cloud.seatable.io/api-gateway/api/v2/dtables/**REMOVED**/rows/?table_name=table_name%3A%20Corsi%20di%20Laurea&view_name=Default%20View';
//=================================
//get data
//=================================
async function fetchTableData() {
try {
const response = await fetch(API_URL, options);
if (!response.ok) {
throw new Error(`Errore ${response.status}: ${response.statusText}`);
}
const data = await response.json();
return data.rows;
} catch (error) {
console.error('Error:', error);
}
}
//=================================
console.log('URL:', API_URL);
console.log('Headers:', options.headers);
//=================================
//insert data into table
async function populateTable() {
const tableBody = document.querySelector('#dataTable tbody');
const rows = await fetchTableData();
//if there is an error while getting data, the foreach will not work!
rows.forEach(row => {
const tr = document.createElement('tr');
tr.innerHTML = `
<td>${row['Nome Corso'] || ''}</td>
<td>${row['Anno'] || ''}</td>
<td>${row['Crediti'] || ''}</td>
`;
tableBody.appendChild(tr);
});
}
//=================================
//update table with page refresh
document.addEventListener('DOMContentLoaded', populateTable);