How to get the spreadsheet ID that is in the URL. I know about using SpreadsheetApp.getActiveSpreadsheet().getId() and SpreadsheetApp.getActiveSpreadsheet().getUrl()
<As David pointed out, the id of the same file is different in the Spreadsheet app and in the Drive app.
Getting the spreadsheet file from the Drive app, using the Spreadsheet id, and then getting the id of the Drive file, following the example, will solve your problem.
You don't show the code that is not working for you, but the following works ok for me
function myFunction() {
// create a new spreadsheet workbook
var ss = SpreadsheetApp.create("Test");
var id = ss.getId();
Logger.log(id)
// get the ss file through Drive using spreadsheet id
var file = DriveApp.getFileById(id);
var driveid = file.getId();
Logger.log(driveid)
// open the spreadsheet using id of file
var ssfromdrive = SpreadsheetApp.openById(driveid);
Logger.log(ssfromdrive.getName())
}