Support

Home Forums Event Espresso Premium REST API not working

REST API not working

Posted: July 13, 2016 at 3:41 am


adminsevenverbs

July 13, 2016 at 3:41 am

Hi Support,

I have installed your premium event espresso plugin on my site and I want to use its REST API but I am getting error here:
https://fellowshipoffiduciaryeducation.com/wp-json/ee/v4.6/events

[{“code”:”json_no_route”,”message”:”No route was found matching the URL and request method”}]

Can you please help me out with this.

Thanks


Josh

  • Support Staff

July 13, 2016 at 11:13 am

Hi there,

Since the REST API wasn’t a part of WordPress core until WordPress 4.5, you’ll need to update your site to have the newer current of WordPress.


adminsevenverbs

July 19, 2016 at 12:46 am

Hi Josh,

Thanks for your reply. I have updated my site “https://fellowshipoffiduciaryeducation.com” to the latest version of wordpress. But still getting the same error as given below:

[{“code”:”json_no_route”,”message”:”No route was found matching the URL and request method”}]

Can you please assist.

Thanks


Tony

  • Support Staff

July 19, 2016 at 3:34 am

Hi there,

It looks like Event Espresso is not currently active on your site, have you de-activated it?


adminsevenverbs

July 19, 2016 at 3:40 am

Hi Tony,

Yes, I tried deactivating and then re-activating the event plugin but still the API is not working. Can you please check what’s the issue.

Thanks
Roma Dahiya


Tony

  • Support Staff

July 19, 2016 at 4:13 am

Do you currently have any REST API plugins listed within Dashboard -> Plugins?


adminsevenverbs

July 19, 2016 at 4:17 am

I have “WP REST API” and “WP REST API Log” installed at my end.


Tony

  • Support Staff

July 19, 2016 at 4:32 am

De-activate the WP REST API plugin (you don’t need that for EE to work, only if you are using the REST API for ‘other’ areas of your site)

Then navigate to Settings -> Permalinks.

Make no changes and save the settings.

We need: https://fellowshipoffiduciaryeducation.com/wp-json/

To load the enpoints before moving any further, I suspect you have V1 of the REST API add-on installed which is causing problems.


adminsevenverbs

July 19, 2016 at 4:52 am

I have deactivated the “WP REST API” plugin and reset the Permalinks.

Actually, I need to use https://fellowshipoffiduciaryeducation.com/wp-json/ee/v4.6/events on one of my third site to display event data on it. So I need the event data via this API.

Thanks


adminsevenverbs

July 19, 2016 at 4:55 am

Now I am getting this error

{“code”:”rest_no_route”,”message”:”No route was found matching the URL and request method”,”data”:{“status”:404}}

Please help


Tony

  • Support Staff

July 19, 2016 at 5:02 am

Actually, I need to use https://fellowshipoffiduciaryeducation.com/wp-json/ee/v4.6/events on one of my third site to display event data on it. So I need the event data via this API.

I understand that you are trying to get the EE data from the REST API, however you need https://fellowshipoffiduciaryeducation.com/wp-json/ to load all of the endpoints, THEN move onto getting EE endpoints to work.

Previously that URL would show:

[{"code":"json_no_route","message":"No route was found matching the URL and request method"}]

Which meant the REST API wasn’t working at all on your site….

Now you have de-activated the V1 plugin, if you take a look here:

https://fellowshipoffiduciaryeducation.com/wp-json/

You’ll notice its loading all the data from EE, meaning its now working as expected.

The reason your getting an error on this url:

https://fellowshipoffiduciaryeducation.com/wp-json/ee/v4.6/events

is because it’s the wrong url. There is no /v4.6/ enpoint, you need to use this:

https://fellowshipoffiduciaryeducation.com/wp-json/ee/v4.8.36/events/

We have some documentation on using the EE REST API here:

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


adminsevenverbs

July 19, 2016 at 5:29 am

Thank for you help. Let me check this and will revert you soon.

Also I would like to know that what does “v4.8.36” means in the url https://fellowshipoffiduciaryeducation.com/wp-json/ee/v4.8.36/events/

Is that something kind of version number?


adminsevenverbs

July 19, 2016 at 5:32 am

Also When I am trying to use https://fellowshipoffiduciaryeducation.com/events/

I get the following error in the error box:

An error has occurred:
The Event Espresso REST API requires the WP REST/JSON API version to be running (the latest stable version of the WP REST/JSON API at the time of writing was 1.2.0)


Tony

  • Support Staff

July 19, 2016 at 5:35 am

Yes, its basically the versions of the API you are using within EE.

When we make changes to the API we create a new version based on the release version number.

So lets so we introduce a new change to how the API works, and we released that with the next version of EE, we may then have:

/wp-json/ee/v4.9.4/

You can continue to use:

/wp-json/ee/v4.8.36/

For the same current functionality (meaning we don’t break of of the existing use cases the REST API is being used for) or if you want to use the next features use the new endpoint. It also means that we can identify the features available to use based on the version number of EE in use on the site and the version of the API in use, there’s a little more to it, but that’s the general idea for the version numbering.


Josh

  • Support Staff

July 19, 2016 at 10:21 am

re: the error. You need to deactivate the Event Espresso REST API plugin as it’s no longer used. The Event Espresso REST API is now included in Event Espresso core.


adminsevenverbs

July 20, 2016 at 1:12 am

Hi Josh, thanks for your reply.

I am a bit stuck right now. I have same plugin setup on my staging site here:

http://fofed-s.sevenverbs.com/

The plugins installed on these are:

Event Espresso – REST API (EE4.x+) – activated
Event Espresso – Grid View Template (EE 4.4.9+) – activated
Event Espresso – Events Table View Template (EE 4.4.9+) – activated
Event Espresso(4.9.3.p)- activated
WP REST API Log – deactivated
WP REST API – deactivated

Still I am unable to access the REST API on my staging/development.

Can you please help me with this issue as soon as possible. Am I doing wrong somewhere?

Thanks


Tony

  • Support Staff

July 20, 2016 at 2:21 am

Event Espresso – REST API (EE4.x+) – activated

Please de-activate and remove this plugin, it is no longer needed as the REST API is now in Event Espresso core

Then flush your permalinks and retest.


adminsevenverbs

July 20, 2016 at 5:16 am

Hi Tony,

I made the above changes and yes its working now. Also I would like to know that is there any changes made in the return json format of the API.

I am getting issue with it if decode it into Csharp. Please have a look at the screenshot below.

http://svmktools.com/ars-bp-d/json.png

Can you please check and verify.

Thanks

Roma Dahiya


adminsevenverbs

July 20, 2016 at 5:30 am

I need a proper key-value pair when decoded in Csharp


Michael Nelson

  • Support Staff

July 20, 2016 at 10:42 am

hey @adminsevenverbs, are you asking if “htts://api.eventespresso.com/datetimes” is the key? Yes it is. And its value is a JSON array, whose individual items are JSON objects with properties “href” (a string) and “single” (a boolean).
The odd-looking array key is a custom link relation, please see http://v2.wp-api.org/extending/linking/ (especially the section on “Custom Link Relations”) for more information on it.
So if by “I need a proper key-value pair” you mean that you need the value to be a simple string: sorry, the WP API v2 and our EE4 REST API don’t provide that. They provide you with a JSON array like I described above.
Does that make sense?


adminsevenverbs

July 20, 2016 at 10:18 pm

Hi Michael Nelson

I am csharp developer. I am decoding your json in csharp.Everthing is working fine.But when I decode link array this what I get.

public class Links
{
public List<Self> self { get; set; }
public List<Collection> collection { get; set; }
public List<HttpsApiEventespressoComRegistration> https://api.example.com/registrations { get; set; }
public List<HttpsApiEventespressoComDatetime> https://api.example.com/datetimes { get; set; }
public List<HttpsApiEventespressoComQuestionGroup> https://api.example.com/question_groups { get; set; }
public List<HttpsApiEventespressoComVenue> https://api.example.com/venues { get; set; }
public List<HttpsApiEventespressoComTermTaxonomy> https://api.example.com/term_taxonomies { get; set; }
public List<HttpsApiEventespressoComMessageTemplateGroup> https://api.example.com/message_template_groups { get; set; }
public List<HttpsApiEventespressoComAttendee> https://api.example.com/attendees { get; set; }
public List<HttpsApiEventespressoComWpUser> https://api.example.com/wp_user { get; set; }
public List<HttpsApiEventespressoComPostMeta> https://api.example.com/post_metas { get; set; }
public List<HttpsApiEventespressoComExtraMeta> https://api.example.com/extra_metas { get; set; }
public List<HttpsApiEventespressoComChangeLog> https://api.example.com/change_logs { get; set; }
}

Csharp does not support special characters in keys like the one above (https://api.example.com/registrations).If it is possible can you please make the keys
like below.

public class Links
{
public List<Self> self { get; set; }
public List<Collection> collection { get; set; }
public List<HttpsApiEventespressoComRegistration> registrations { get; set; }
public List<HttpsApiEventespressoComDatetime> datetimes { get; set; }
public List<HttpsApiEventespressoComQuestionGroup> question_groups { get; set; }
public List<HttpsApiEventespressoComVenue> venues { get; set; }
public List<HttpsApiEventespressoComTermTaxonomy> term_taxonomies { get; set; }
public List<HttpsApiEventespressoComMessageTemplateGroup> message_template_groups { get; set; }
public List<HttpsApiEventespressoComAttendee> attendees { get; set; }
public List<HttpsApiEventespressoComWpUser> wp_user { get; set; }
public List<HttpsApiEventespressoComPostMeta> post_metas { get; set; }
public List<HttpsApiEventespressoComExtraMeta> extra_metas { get; set; }
public List<HttpsApiEventespressoComChangeLog> change_logs { get; set; }
}

Looking forward to hear a positive response from you.This is going to great help for me and other developer working with Event Espresso API.

Thanks


adminsevenverbs

July 21, 2016 at 4:06 am

Hi Michael,

Is there any updates regarding the query above. I need solution to this problem as soon as possible. Kindly assist.

Thanks


Michael Nelson

  • Support Staff

July 21, 2016 at 10:47 am

Hi @adminsevenversb, I’ve only worked in C sharp once. What library or code are you using to generate Csharp code from our JSON responses?
Changing the keys to what you have suggested could break other API clients which are already expecting those exact strings. Also, what we’ve implemented, from what I’ve read, is what the WordPress REST API team recommends (see the link I posted above). If you’d like them to change their recommendation please open an issue with them on github: https://github.com/WP-API/WP-API/issues

For now, I would suggest one of the following:

1. Before parsing the JSON, you could perform a string replace on it. ie, remove all the strings like “https://api.eventespresso.com/wp_user” and replace with “httpsapieventespressocomwp_user” etc.
2. On your requests, use the “include” parameter in order to exclude the links JSON property from your responses entirely. See https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-GET-including-specific-fields-and-related-entities-in-results.md


adminsevenverbs

July 21, 2016 at 9:59 pm

Hi Michael

Thanks for you response here.
1). I can not used replace on entire string like you suggested because it will perform replace on values also not only keys that I need. Doing this will result in unwanted result.

4). I can not exclude those values. I need those in proper format that’s why I am here with an issue.

Thanks


Josh

  • Support Staff

July 22, 2016 at 8:26 am

You can’t do a string replace on the keys you need changed? We’re really not in a position to make a breaking change to the API as that will affect everyone else that’s already using the API.

The support post ‘REST API not working’ 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