Wix-events-backend: createEvent() FORBIDDEN

Dear People with a lot more experience than me:
I’m facing an weird issue:

I try to code a backend site, where wixEvents can be created by the user.
I used the documentation below, corrected the imbedded mistakes as other users described them (country codes, time formats, etc) but facing this odd behavior:

Running the code (in Preview - so that permission issues should not be a problem) returns an error message with following indications:

message: ‘’
details: applicationError:
description: Forbidden
code: FORBIDDEN
data: {}

I am afraid it is an internal bug. Is there any workaround, or does my path simply end there…?

Thanks a lot

import { wixEvents } from “wix-events-backend” ;

const eventInfo = {
title : “Testevent” ,
location : {
name : “Testname” ,
address : {
formatted : “Hauptstrasse 12, Seeg, 87637, DE” ,
city : “Seeg” ,
subdivision : “Test” ,
country : “DE” ,
postalCode : “87637” ,
streetAddress : {
number : “12” ,
name : “Hauptstrasse” ,
apt : “10”
}
},
type : ‘VENUE’ ,
},
scheduling : {
timeZoneId : “Europe/London” ,
startDate : new Date ( “2024-09-25T12:00:00Z” ),
endDate : new Date ( “2024-09-26T12:00:00Z” )
},
registration : {
initialType : ‘RSVP’
}
};

const options = {
language : “en”
};

export function myCreateEventFunction () {
console . log ( “BACKEND: myCreateEventFunction()…” );

return wixEvents . createEvent ( eventInfo , options )
. then (( result ) => {
return result ;
})
. catch (( error ) => {
console . error ( error );
});
}

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

Play the games!

Safety and security are paramount when it comes to online gambling and sports betting. Rest assured that Sona9 App Download for Android (APK) and iOS in India 2023 India prioritizes the protection of your personal and financial information. With robust encryption and stringent privacy measures, you can enjoy your gaming experience with peace of mind.