Support

Home Forums Event Espresso Premium Add an Event via the API

Add an Event via the API

Posted: July 19, 2018 at 5:54 pm

Viewing 7 reply threads


gncares

July 19, 2018 at 5:54 pm

The documentation isn’t very clear as to what I need.

I’m doing a POST with this:

EVT_name=Event+Testing&EVT_short_desc=Short+description+of+the+event.&EVT_desc=This+is+the+long+description+of+the+event.&EVT_visible_on=2018-07-26T16:49:46

Looking at what’s returned to me if I just query an event manually created, I don’t see any variables for setting the Start and End Dates, how many people are allowed to sign up, etc…


gncares

July 20, 2018 at 6:08 pm

No one?


Josh

  • Support Staff

July 23, 2018 at 8:51 am

Hi,

Here’s a link to the documentation:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-writing-data.md

The documentation shows how you can discover what’s needed to write to a specific entity. Examples of entities related to the event include the datetimes, tickets, datetime_tickets, prices, venues.


gncares

July 23, 2018 at 5:42 pm

Ok, I know I’m missing something very basic here….

I’m posting (switched to Json) this:

{
“Event”: {
“EVT_name”: “Event Testing”,
“EVT_desc”: “This is the long description of the event.”
},
“Ticket”: {
“TKT_name”: “Test Ticket”,
“TKT_start_date_gmt”: “2018-07-30T16:40:41”
}
}

and I get an error:

{“code”:”invalid_field”,”message”:”You have provided an invalid parameter: "Event"”,”data”:null}

What am I missing here?


Josh

  • Support Staff

July 23, 2018 at 6:09 pm

The documentation has what you’re missing. So for example, to create a new event, send a POST request to the resource’s collection route. Eg, to create a new event entity, send it to ee/v4.8.36/events. Then to create a new ticket, send a POST request to ee/v4.8.36/tickets.

The documentation shows how to create a new answer, and if you follow the example given there it’s very similar to creating other types of data.

Also, it looks like you’re trying to create two entries simultaneously. The REST API doesn’t actually work that way. Instead, you will need to create each record individually, one per request.


gncares

July 23, 2018 at 7:50 pm

So how do I relate the Ticket to the Event? I don’t see any fields that would allow the relating of the them together.


Josh

  • Support Staff

July 24, 2018 at 9:40 am

You relate the datetime to the event.
https://slack-files.com/T02SY781D-FBW5RS4E9-2c3001020d

Then, you relate a ticket to a datetime by sending a POST request to /datetime_tickets.
https://slack-files.com/T02SY781D-FBVT686AF-df3a4aba7d


gncares

July 26, 2018 at 1:06 am

Got it working, thank you for your help.

Viewing 7 reply threads

The support post ‘Add an Event via the API’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso