How to Create an Event Using the Meetup.com API

Meetup.com has a well-documented API that gives you all the information about your events you can think of. Getting the attendees, the pictures taken at your event or the comments is easy, you can even try everything out online without writing a single line of code. That great developer support unfortunately ends rather abruptly when it comes to creating an event using the API. There is no online demo and the documentation itself guides you into the wrong direction.

 

Prerequisites

You need your API key and a group in which you can create events. Without either one of them it will be impossible to try the code of this post on your own.

 

JSON does not work

The API for all the GET requests delivers JSON back and that my give you the idea that you can create a JSON message with your event and post it to the server. I tried this but only got this useless error message:

 

Post a form using FormUrlEncodedContent

The documentation for creating events contains a easy to miss heading named Request Parameters. This is exactly what you need to create an event: not JSON, but a plain simple old boring form request. The fields must be named exactly as they are written in the documentation, including the _ and everything must be in lower case.

A few important parts to point out with the code above:

  • The types for the KeyValuePair in the FormUrlEncodedContent must be both strings. Otherwise you may get an error.
  • When publish_status is set to draft, you can see your newly created event on meetup, but the members of your group will not get an email about a new event. When everything works you can change it to published.
  • The event_hosts property can contain multiple hosts. However, it only works when you have numer,number without any spaces.
  • Converting a System.DateTime to milliseconds since the epoch needs a few method calls. Do not forget the conversion to UTC or the start time of your event will be off by a few hours.
  • The duration is in milliseconds, what makes not much sense but needs to be considered when you want to change it from the default (3 hours).
  • The response for your created event is in JSON. You can use the response string to create a class using the Paste JSON as classes feature of Visual Studio and then deserialize it with Newtonsoft.JSON into an instance of that class.

 

Conclusion

As soon as you drop the idea of using JSON and go back to the old days of forms you can create events with the Meetup API without any problems. It would be great if that little detail would be written directly in the documentation – that would have saved us hours of trying the wrong approach.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.