Support

Home Forums Ticketing Add-on EE3 JSON API error 400

EE3 JSON API error 400

Posted: November 21, 2017 at 3:33 am


jansan20

November 21, 2017 at 3:33 am

Hi,

I need the mobile ticketing app to work with JSON API. However, it does not display any events currently.

1. I have public access set to “allow”
2. I am using a separate administrator WP account for API purposes.
3. I have switch off any plugins that may have interfere (Sucuri, W3TC, etc.)

I started troubleshooting according to https://eventespresso.com/wiki/json-api-add-on/ .

Opening http://testdrive.eventespresso.com/espresso-api/v1/events/public.pretty_json/
gives me

{
“status”: “Param registration_start with value -0001-11-30 00:01:00 is not of allowed type datetime.”,
“status_code”: 400
}

Trying this:
https://vikingtenerife.com/espresso-api/v1/events/?registration_start__gt2017-03-24%2012:23:56

gives me:
{“status”:”Invalid request. You should also provide a resource, eg: ‘events’. You only provided the following api key:”,”status_code”:400}

Whenever I do the same but with a previously requested session id, I get the same results.

I’d be very grateful for any advice.

Jan


Josh

  • Support Staff

November 21, 2017 at 12:32 pm

Hi Jan,

The error message indicates that the events’ registration_start (and possibly registration_end) values are not correctly formatted.

If you check the demo site:

http://testdrive.eventespresso.com/espresso-api/v1/events/public.pretty_json/

you’ll see the registration_start values are formatted like this:
2016-03-08 00:00:00

or

YYYY-MM-DD


jansan20

November 22, 2017 at 3:36 am

Hi,

Thanks for the quick reply.

First of all, I noticed that the first link provided is wrong in that it links to your testdrive site instead of my website, but the error message is the same.

Now, I am sorry, but I do not fully understand your response.

I am not specifying anything in the request itself when trying to pull some events. But even if I do like this:

https://vikingtenerife.com/espresso-api/v1/events/eu6da02zg5/?registration_start__gt2017-03-24&registration_end__lt2017-11-20

the error message stays the same.

{“status”:”Param registration_start with value -0001-11-30 00:01:00 is not of allowed type datetime.”,”status_code”:400}

When I type in something like this:
https://vikingtenerife.com/espresso-api/v1/events/

I also get:
{“status”:”Invalid request. You should also provide a resource, eg: ‘events’. You only provided the following api key:”,”status_code”:400}

But the resource is “events”, isn’t it?

The mobile app (regardless of whether it is iOS or Android) struggles to get any events.

Version 2.26 of the Android app says: “No route was found matching the URL and request”

Version 2.0 of the Android app logs in successfully, but then shows “0 events shown of 0 loaded”

Version 2.6.3 of the iOS app apparently logs in correctly, but states: “Error Occurred, The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.”

I tried deleting the plugin entirely and reinstalling it, but to no avail.

Can you further specify how to solve this problem? Where is the date which is formatted wrongly? Did I set up my events incorrectly?

Thanks in advance,


Josh

  • Support Staff

November 22, 2017 at 8:35 am

The dates which are formatted wrong are set within the event editor. The dates labeled “Registration Dates” and “Registration Starts On” and “Registration Ends On”. Those dates need to be formatted as follows:

YYYY-MM-DD


jansan20

November 23, 2017 at 1:44 am

Hi Josh,

I set these dates using the datepicker included in the event editor. I do not type them in by hand.
Also, they are in the mentioned format, eg. “2017-11-24” .

What is in a different format is the overall date setting for WordPress, which is DD/MM/YYYY, eg “23/11/2017”. However, as far as I know, the overall WordPress date setting does not influence the EE3 date format.

Now, what I usually do, is leave the registration start field blank, since the created event can immediately be made available for registration. The system then applies the beginning of Unix time automatically, which is fine, and it used to work with JSON API.

I tried setting the WordPress date format so that it complies with what you wrote, but to no avail.

Can you give me any further advice?


Tony

  • Support Staff

November 23, 2017 at 10:39 am

Its likely just one of your events that have a registration date set with the wrong format.

One way to find out which event is causing this is to temporarily disable the validation on the date format so that its output to the JSON output and we can find the event ID.

To do this you’ll need to use FTP and navigate to \wp-content\plugins\espresso-json-api\includes\helpers\EspressoAPI_Validator.class.php

On line 267-272 you should have:

case 'datetime':
	if(preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/',$value)){
	continue;
}else{
	return false;
}

Change return false; to continue;.

Then check your JSON output and search for -0001-11-30 00:01:00 to find the event, find the event id and fix it within the admin.

Note the above file should then be reverted back, the validation confirms your data is in the correct format, removing it will cause you more problems in the long run but the above allows you to find the event causing the problem.


jansan20

November 25, 2017 at 7:56 am

Thanks a million Tony,

What you described allowed me to identify a few of my events having a negative registration_start date.

“Datetimes”: [
{
“id”: 22036,
“is_primary”: true,
“event_start”: “2017-12-05 13:45:00”,
“event_end”: “2017-12-05 15:45:00”,
“registration_start”: “-0001-12-28 00:01:00”,
“registration_end”: “2017-12-04 20:00:00”,
“limit”: 80,
“tickets_left”: 80
}
],

I assume this is because I worked on later events in a series, leaving the registration start field blank, which led to it taking the beginning of Unix time.

Then, according to the recurring events formula, it set the registration start dates for previous events back, leading to the negative dates.

At least now, I can identify exactly the problem and fix it.

Thanks again.


jansan20

November 25, 2017 at 11:20 am

One last question and this can be close :).

Am I right to assume that the newest mobile app (IOS HD version and Android 2.26 version), simply will not work with EE3? Or is there a way to make them work?

Problem is that the IOS version of the App, no longer works with IOS 11. It requires an update apparently, but the newer IOS version of the App, won’t work with EE3. Unfortunately we are dependent on the recurring event functionality of EE3, so we cannot upgrade.


Tony

  • Support Staff

November 27, 2017 at 2:34 am

Am I right to assume that the newest mobile app (IOS HD version and Android 2.26 version), simply will not work with EE3?

There’s a version of the apps for EE3 and EE4, from the above I think you are referring to the EE4 versions and if so then no they will not work with EE3.

Or is there a way to make them work?

Not if the above is correct, the structure is completely different for each version.

In iOS 11 Apple removed support for 32bit apps so the EE3 app won’t work on iOS and updating the EE3 app is not something we are looking into at this time, meaning you would need to use either an older iOS device or android for EE3.

The support post ‘EE3 JSON API error 400’ 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