Hello,
I’m trying to create a booking resource programmatically in the backend using the following code snippet, which wraps the resources.createResource
function with elevate()
from wix-auth
:
import { elevate } from 'wix-auth';
import { resources } from 'wix-bookings-backend';
const elevatedCreateResource = elevate(resources.createResource);
export async function createResourceWithElevatedPermissions() {
const resourceInfo = {
name: "Nuevo recurso",
type: "INDIVIDUAL",
locationOptions: {
specificLocationOptions: {
availableInBusinessLocations: true
}
}
};
const scheduleInfo = [
{
availability: {
linkedSchedules: [],
start: new Date(),
},
},
];
const options = { suppressAuth: true };
try {
const result = await elevatedCreateResource(resourceInfo, scheduleInfo, options);
return result;
} catch (error) {
console.error("Error creating resource:", error);
throw error;
}
}
Despite using elevate()
and passing suppressAuth: true
in options, I still receive a 403 Forbidden error when executing this function.
Has anyone else experienced this? Could it be that Wix has restricted the creation of booking resources via API recently?
Thanks in advance for any help!