How to create an Event via API
-
Hello, I am somewhat of a wordpress newbie, and I am trying to create events using a python script I am running. I have wordpress and events calendar working properly, but I cannot seem to figure out the API to properly create an event.
Here is the code I am using:
url = "https://mywebsite.com/wp-json/wp/v2/tribe_events" user = "jjohns99" password = "SuPR CreT ApPP PaSs W0rD 1234" credentials = user + ':' + password token = base64.b64encode(credentials.encode()) header = {'Authorization': 'Basic ' + token.decode('utf-8')}
post = {
‘title’ : ‘My Event Title’,
‘status’ : ‘publish’,
‘content’ : ‘My Event Description’,
‘post_type’: ‘Events’,
‘start_date’: ‘2022-08-31 15:00:00’,
‘end_date’: ‘2022-08-31 20:00:00’,
‘cost’: ’20’,
‘website’: ‘https://event.com/eventperformances.asp?evt=123’,
‘venue’:{
‘id’: 23
}}response = requests.post(url , headers=header, json=post)`
It will create the event just fine, add the title and description, but I for the life of me cannot figure out how to add the start and end date, and venue location. I currently have venues created, and I just want to select an existing one (by ID or Name)
- The topic ‘How to create an Event via API’ is closed to new replies.