script returns
I am trying to get the attendance not taken for today, but this script returns:
{"statusCode":401,"message":"The required Authorization header was missing or invalid, or the token has expired","status":401,"title":"The required Authorization header was missing or invalid, or the token has expired"}
Any advice?
Thank you very much!
SCript:
function fetchAndUpdateAttendanceData() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Attendance Not Taken Today");
// Clear previous data except for the header row
if (sheet) {
var lastRow = sheet.getLastRow();
if (lastRow > 1) {
sheet.getRange(2, 1, lastRow - 1, sheet.getLastColumn()).clearContent();
}
}
// Correct the apiUrl construction (ensure correct concatenation)
var listId = 86555;
var apiUrl = 'https://api.sky.blackbaud.com/school/v1/lists/advanced/' + listId; // Ensure the list endpoint is correct
// Add your API subscription key here
var subscriptionKey = 'a06a7d071baa44xxxxxxx36b6984fb'; // Replace with your actual subscription key, keep it secure
// Set up headers for the API request with the correct key name
var options = {
'method' : 'GET',
'headers': {
'Bb-Api-Subscription-Key': subscriptionKey, // The correct header for Blackbaud's SKY API
'Content-Type': 'application/json'
},
'muteHttpExceptions': true // Allows full error response to be logged
};
// Fetch the attendance data
try {
var response = UrlFetchApp.fetch(apiUrl, options);
// Log the full response (will help identify exact error or confirm success)
Logger.log(response.getContentText()); // This will log the entire response, including error details
// Parse the response
var data = JSON.parse(response.getContentText());
// Assume 'data' is an array of attendance records (adapt this if structure differs)
var attendanceRecords = data.value || []; // Replace with actual response structure
// Populate the sheet with new data
if (attendanceRecords.length > 0) {
for (var i = 0; i < attendanceRecords.length; i++) {
var row = attendanceRecords[i];
sheet.appendRow([row.studentName, row.status, row.time]); // Replace with your fields
}
} else {
Logger.log('No attendance records found.');
}
} catch (e) {
Logger.log("Error fetching attendance data: " + e.toString());
}
}
Comments
-
0
Categories
- All Categories
- New YourCause Community TEST
- New SKY Community TEST
- New Grantmaking TEST Community
- New Altru Test Community
- New bbcon Community - TEST
- 12 Blackbaud Agents for Good™
- New Raiser's Edge NXT Community
- 7 Blackbaud Community Help
- 218 bbcon®
- 1.4K Blackbaud Altru®
- 409 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.2K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 16 donorCentrics®
- 361 Blackbaud eTapestry®
- 2.7K Blackbaud Financial Edge NXT®
- 680 Blackbaud Grantmaking™
- 598 Blackbaud Education Management Solutions for Higher Education
- 3.3K Blackbaud Education Management Solutions for K-12 Schools
- 952 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 85 JustGiving® from Blackbaud®
- 7K Blackbaud Raiser's Edge NXT®
- 3.9K SKY Developer
- 255 ResearchPoint™
- 122 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 246 Member Lounge (Just for Fun)
- 40 Blackbaud Community Challenges
- 37 PowerUp Challenges
- 3 (Closed) PowerUp Challenge: Grid View Batch
- 3 (Closed) PowerUp Challenge: Chat for Blackbaud AI
- 3 (Closed) PowerUp Challenge: Data Health
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 822 Community News
- 3.1K Jobs Board
- 57 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)