Message: '' details: applicationError: description: Forbidden code: FORBIDDEN data: {}

I have a function that I want to use as a cron task. It works great in testing mode (screenshot).


But during execution on cron an error occurs:
“message: ‘’ details: applicationError: description: Forbidden code: FORBIDDEN data: {}”
I found out that the error occurs in this code:

const availability = await availabilityCalendar.queryAvailability({
    filter: {
        serviceId: serviceIds,
        startDate: startDate,
        endDate: endDate
    }
}, {
    timezone: 'Europe/Warsaw'
});

I tried like this:

const { availabilityEntries } = await webMethod(
    Permissions.Anyone,
    async (serviceIds, startDate, endDate) => {
        const availability = await availabilityCalendar.queryAvailability({
            filter: {
                serviceId: serviceIds,
                startDate: startDate,
                endDate: endDate
            }
        }, {
            timezone: 'Europe/Warsaw'
        });
        return availability; 
    }
)(serviceIds, startDate, endDate);

and

const { availabilityEntries } = await webMethod(
    Permissions.Anyone,
    async (serviceIds, startDate, endDate) => {
        const elevatedQueryAvailability = elevate(availabilityCalendar.queryAvailability);
        const availability = await elevatedQueryAvailability({
            filter: {
                serviceId: serviceIds,
                startDate: startDate,
                endDate: endDate
            }
        }, {
            timezone: 'Europe/Warsaw'
        });
        return availability; 
    }
)(serviceIds, startDate, endDate);

But the error still occurs.
Please suggest possible solutions.

Is it not working even after elevating the function?
Try exporting the function and recheck the function name in your cron job?