Web Services

Retrieving Events

Retrieving the List of Events

curl http://hostname/webservice/events \
  -u webservice:apikey \
  -G \
  -d filter[include_closed]=true|false

The result is an XML document containing the events that match the filter criteria (if specified). If no filter criteria were given, all events except the closed ones are returned. Each event is contained in an event element. The event elements are contained in an events element.

The filter filter[include_closed], whose value can be true or false(the default), allows you to also include closed events in the search result.

<?xml version="1.0" encoding="UTF-8"?>
<events type="array">
  <event>
    <closed type="boolean">false</closed>
    <closed_at nil="true"></closed_at>
    <details>wine, snacks, arrival, car, rockets</details>
    <ends_at type="datetime">2010-10-03T00:00:00+02:00</ends_at>
    <id type="integer">1</id>
    <name>back2010</name>
    <starts_at type="datetime">2010-10-01T00:00:00+02:00</starts_at>
    <title>Back 2010</title>
  </event>
  <event>
   ...
  </event>
</events>

Retrieving a Particular Event

You can retrieve a particular event by specifying its ID or its name:

curl http://hostname/webservice/events/id \
  -u webservice:apikey

curl http://hostname/webservice/events \
  -u webservice:apikey \
  -G \
  -d filter[name]="event_name"

The result is the queried event whose data is contained in the event element:

<?xml version="1.0" encoding="UTF-8"?>
<event>
  <closed>false</closed>
  <closed_at type="datetime">2010-07-13T16:00:36+02:00</closed_at>
  <details>wine, snacks, arrival, car, rockets</details>
  <ends_at type="datetime">2010-07-03T00:00:00+02:00</ends_at>
  <id type="integer">1</id>
  <name>Sommer Event</name>
  <starts_at type="datetime">2010-07-01T00:00:00+02:00</starts_at>
  <title>sommer_event</title>
</event>

Creating and Modifying Events

Creating an Event

An event can be created by means of a POST request. You need to specify at least the name of the event using the event[name] parameter.

curl http://hostname/webservice/events \
  -u webservice:apikey \
  -X POST \
  --form-string event[name]='new_event_name' \
  --form-string event[title]='New Event Title' \
  --form-string event[starts_at]='2008-12-31T00:00:00+01:00' \
  --form-string event[ends_at]='2009-01-01T01:00:00+01:00' \
  --form-string event[details]='day1, day2'

As the result, the new event is returned:

<?xml version="1.0" encoding="UTF-8"?>
<event>
  <closed type="boolean">false</closed>
  <closed_at nil="true"></closed_at>
  <details>day1, day2</details>
  <ends_at type="datetime">2009-01-01T01:00:00+01:00</ends_at>
  <id type="integer">3</id>
  <name>new_event_name</name>
  <starts_at type="datetime">2008-12-31T00:00:00+01:00</starts_at>
  <title>New Event Title</title>
</event>

Modifying an Event

To modify the data of an event, use a PUT request and specify the event ID in the URL as well as the fields to be changed in the body of the request:

curl curl http://hostname/webservice/events/id \
  -u webservice:apikey \
  -X PUT \
  --form-string event[title]="Invitation to next summer's product show"

As with event creation, the OMC returns the data of the event.

Retrieving and Modifying Participant Data

Retrieving the Participant List of an Event

curl http://hostname/webservice/events/id/contacts \
  -u webservice:apikey

The result is the list of participants which is contained in the event_contacts element. Each participant’s data is contained in an event_contact subelement. A participant’s fields can be found in her individual details element.

<?xml version="1.0" encoding="UTF-8"?>
<event_contacts type="array">
  <event_contact>
    <contact_id type="integer">1</contact_id>
    <details>
      <car>true</car>
      <snacks>popcorn, chocolate</snacks>
    </details>
    <event_id type="integer">1</event_id>
    <id>1</id>
    <state>reg</state>
  </event_contact>
  <event_contact>
    <contact_id type="integer">2</contact_id>
    <event_id type="integer">1</event_id>
    <details>
      <car>true</car>
      <snacks>popcorn, chocolate</snacks>
    </details>
    <id>2</id>
    <state>reg</state>
  </event_contact>
</event_contacts>

Retrieving a Particular Event Participant

curl http://hostname/webservice/events/id/contacts/contact_id \
  -u webservice:apikey

The result is the participant’s data which is contained in the event_contact element. The participant can be identified by means of the contact_id subelement:

<?xml version="1.0" encoding="UTF-8"?>
<event_contact>
  <contact_id type="integer">2</contact_id>
  <details>
    <car>true</car>
    <snacks>popcorn, chocolate</snacks>
  </details>
  <event_id type="integer">1</event_id>
  <id>2</id>
  <state>reg</state>
</event_contact>

Modifying an Event Participant’s Data

To modify the data of an event participant, use a PUT request according to the following web service call and specify the fields to be changed:

curl http://hostname/webservice/events/id/contacts/contact_id \
  -u webservice:apikey \
  -X PUT \
  --form-string event_contact[details][car]="false" \
  --form-string event_contact[state]="att"

As with querying a participant, the result is the data of the participant referenced by the contact_id field. The data can be found in the event_contact element.