Hey,
Thanks for reaching out!
In order to use this successfully you need elevated permissions ( docs ):
import { wixEvents } from "wix-events-backend";
import * as wixAuth from "wix-auth";
const elevatedCreateEventFunction = wixAuth.elevate(wixEvents.createEvent);
const eventInfo = {
title: "Healthy Living Series: Exercise and You",
location: {
name: "Community Hall",
address: {
formatted: "100 Gansevoort St, New York, NY 10014, USA",
city: "New York City",
subdivision: "New York",
country: "US",
postalCode: "10014",
streetAddress: {
number: "100",
name: "Gansevoort Street",
apt: "10"
}
},
type: 'VENUE',
},
scheduling: {
startDate: new Date("2023-09-14T13:30:00.000Z"),
endDate: new Date("2023-09-14T15:30:00.000Z"),
timeZoneId: "America/New_York"
},
registration: {
initialType: 'RSVP'
}
};
const options = {
language: "en"
};
export function myCreateEventFunction() {
return elevatedCreateEventFunction(eventInfo, options)
.then((result) => {
return result;
})
.catch((error) => {
console.error(error);
});
}
Hope it helps!
Regards,
Kristina