Date Format in API Create Event POST
When creating new events (these are simple RSVP events) via the API interface, the web interface shows the new event in the default timezone of the Wild Apricot account. This means my start date is almost always wrong for these events.
If I am creating a. new event for Utah, for example, I have set the timezone fields of the API payload as follows ;
"Details": {
"DescriptionHtml": "A fun family event",
"PaymentInstructions": "None",
"TimeZone": {
"ZoneId": "USA & Canada",
"Name": "Mountain Time",
"UtcOffset": -6
},
<truncated>
. When I run my POST command I get back an event_id as a response, indicating successful creation of event.
However when I check in the web interface, my event is listed but on the wrong day as the account default is Pacific time.
How can I set the correct date for my new event via the API ?
Additionally event though this is a simple event (RSVP EventType), it seems I need to set "sessions StartDate" for my new event to be created. If I set that "sessions StartDate = None", I get a validation error indicating it is required field.
However the Swagger API only shows the Event StartDate as the required field, but I can set that to "None" and still create my event.
Is there another attribute that is required to be set to False to stop sessions. My events are mostly single day events with no multiple sessions.
-
Grant Cooper commented
Thank you Vassily Kholopov,
I had tried using ISO8601 format and that was successful.
I just now also tried your suggestion of simply including an offset and that also worked.
This has solved my question.
-
Hello!
the correct date format should include time zone offset.
try to use
"StartDate": "2022-10-15 AM -6:00", -
Grant Cooper commented
Another update.
I am passing this event dictionary (using Python language) to my create_event function.
event = {
"Name": "Test Event 8",
"EventType": "RSVP",
"StartDate": "2022-10-15",
"StartTimeSpecified": False,
"EndDate": "2022-10-15",
"EndTimeSpecified": False,
"Location": "Quail Creek, St George Utah",
"RegistrationEnabled": False,
"Tags": [
"rockies",
"local series"
],
"Details": {
"DescriptionHtml": "A fun family event",
"TimeZone": {
"ZoneId": "Mountain Standard Time",
"Name": "(UTC-06:00) Salt Lake City",
"UtcOffset": 360
},
"AccessControl": {
"AccessLevel": "Public"
},
}
}My event is being created and now shows the correct time zone, however the start date in the web interface is still 1 day earlier than I set in my POST request via the API.
We can see in the dictionary snippet above the StartDate is "2022-10-15", but in the attached screen capture the web interface shows October 14th.
How do I set this correctly ?
-
Grant Cooper commented
As an update, t seems I have resolved the sessions StartDate issue. I had simply copied the payload from the Swagger API example and if "sessions" is included then it must be set. I deleted that section entirely from my payload of the POST command and it the create_event call still worked successfully.
The setting of the Event=> Details => TimeZone is still an issue however.