Support

Home Forums Event Espresso Premium JSON API using GET /registrations returns 500 error

JSON API using GET /registrations returns 500 error

Posted: February 16, 2016 at 3:45 pm

Viewing 15 reply threads


MAC Webmaster

February 16, 2016 at 3:45 pm

Following the instructions to get information for events is working:
http://mysite/espresso-api/v1/events/ge44mm8st4 returns the list of events and works as expected.

But trying to GET /registrations (http://mysite/espresso-api/v1/registrations/ge44mm8st4) returns
{
“status”: “Response in wrong format. For more information please turn on WP_DEBUG in wp-config”,
“status_code”: 500
}

or trying to POST/PUT /registrations (POST http://mysite/espresso-api/v1/registrations/ge44mm8st4)

({
“status”: “Response in wrong format. For more information please turn on WP_DEBUG in wp-config”,
“status_code”: 500
}

Need some help creating an event registration using a POST/PUT to http://mysite/espresso-api/v1/registrations/ge44mm8st4?

Thanks.


Tony

  • Support Staff

February 17, 2016 at 3:00 am

Hi there,

If you enable WP_DEBUG it should show additional information when you test again.

If you can post that info here it will help narrow the cause down.


MAC Webmaster

February 17, 2016 at 6:45 am

here is the extra information returned in debug mode:

{
“status”: “Registration in wrong Event Espresso Format! Expected value: Event but it wasnt set in Array\n(\n [id] => 4488.0\n [status] => approved\n [date_of_registration] => 2012-12-10 16:12:31\n [final_price] => 10.00\n [code] => 1-50c67a6f172e1\n [url_link] => \n [is_primary] => 1\n [is_group_registration] => 1\n [is_going] => 1\n [is_checked_in] => 1\n [Event] => \n [Attendee] => Array\n (\n [id] => 4488\n [firstname] => fromapi\n [lastname] => fromapiman\n [address] => \n [address2] => \n [city] => \n [state] => \n [country] => \n [zip] => \n [email] => michael@eventespresso.com\n [phone] => \n [comments] => \n [notes] => \n )\n\n [Transaction] => Array\n (\n [id] => 4488\n [timestamp] => 2012-12-10 16:12:31\n [total] => 10.00\n [amount_paid] => 0.00\n [status] => pending\n [details] => \n [tax_data] => \n [session_data] => \n [payment_gateway] => Check\n )\n\n [Datetime] => Array\n (\n [id] => 0\n [is_primary] => 1\n [event_start] => 09:00:00\n [event_end] => 17:00:00\n [registration_start] => 00:00:00\n [registration_end] => 00:00:00\n [limit] => 0\n [tickets_left] => 0\n )\n\n [Price] => Array\n (\n [id] => 0\n [amount] => 10.00\n [name] => General Admission\n [description] => \n [limit] => 9999999\n [remaining] => 999999\n [start_date] => \n [end_date] => \n [Pricetype] => Array\n (\n [id] => 1\n [name] => Base Price\n [is_member] => \n [is_discount] => \n [is_tax] => \n [is_percent] => \n [is_global] => 1\n [order] => 0\n )\n\n )\n\n)\n. “,
“status_code”: 500
}

there is much more but this is the extra information returned from the response to this call.

Any help is appreciated.

Thanks.


MAC Webmaster

February 17, 2016 at 6:49 am

After looking at the output a little more closely here is some more information just before the response is returned that might also be useful.

Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /…/html/wp-includes/functions.php:3792) in /…/html/wp-content/plugins/event-espresso/espresso.php on line 80

Notice: Undefined index: ticket_reservation_time in /…/html/wp-content/plugins/event-espresso/includes/functions/main.php on line 599

Warning: Cannot modify header information – headers already sent by (output started at /…/html/wp-includes/functions.php:3792) in /…/html/wp-content/plugins/espresso-json-api/includes/helpers/EspressoAPI_Response_Formatter.class.php on line 47


MAC Webmaster

February 17, 2016 at 10:29 am

A little more detail that I missed including:

The previous response and related information was for a POST to create a new registration.

I just ran a request to GET to retrieve all registrations:

GET http://mysite/espresso-api/v1/registrations/{ge44mm8st4}

and It doesn’t return much at all?

Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /opt/www/mac-apps.ca/html/wp-includes/functions.php:3792) in /opt/www/mac-apps.ca/html/wp-content/plugins/event-espresso/espresso.php on line 80

Warning: Cannot modify header information – headers already sent by (output started at /opt/www/mac-apps.ca/html/wp-includes/functions.php:3792) in /opt/www/mac-apps.ca/html/wp-includes/pluggable.php on line 1228


Josh

  • Support Staff

February 17, 2016 at 1:00 pm

here’s your clue from the debug message:
Registration in wrong Event Espresso Format! Expected value: Event but it wasnt set in Array

You can follow the format used in the documentation, which show an example where it includes the event information in the request:

https://eventespresso.com/wiki/json-api-add-on/#POST.2FPUT_.2Fregistrations


MAC Webmaster

February 17, 2016 at 1:15 pm

Thanks for the response. I actually did that using the exact demo request from the documentation. I can try it again and see if I missed anything from the request. I still don’t understand the issue I get attempting to get a list of all registrations I mentioned before.

Trying to GET /registrations (http://mysite/espresso-api/v1/registrations/ge44mm8st4) returns
{
“status”: “Response in wrong format. For more information please turn on WP_DEBUG in wp-config”,
“status_code”: 500
}


Josh

  • Support Staff

February 17, 2016 at 1:43 pm

It might be the Warning: session_start(): Cannot send session cache limiter – headers already sent error. There’s a good guide on how to debug that warning here:

https://codex.wordpress.org/FAQ_Troubleshooting#How_do_I_solve_the_Headers_already_sent_warning_problem.3F


MAC Webmaster

March 3, 2016 at 12:18 am

I am still having the same probblem? I can’t GET or POST a registration? I have tried what you have suggested so far. Any further ideas?

Thanks.


Tony

  • Support Staff

March 3, 2016 at 4:16 am

If you create a new event within the admin (not using the api)

Then add a new registration to that event, again without trying to use the API.

Then view the registrations specifically for that event:

http://mysite/espresso-api/v1/events/{event_id}/registrations/{session_key}

What is displayed then?

  • This reply was modified 8 years, 7 months ago by Tony.


MAC Webmaster

March 4, 2016 at 1:55 pm

Hi Tony,

I did as you suggested and this is what I see when I run http://mysite.com/espresso-api/v1/events/133/registrations/{session_key}

{
“status”: “OK”,
“status_code”: 200,
“body”: {
“Registrations”: [
{
“id”: 4498,
“status”: “approved”,
“date_of_registration”: “2016-03-04 15:38:51”,
“final_price”: 0,
“code”: “133-56d9f25bc9026”,
“url_link”: “”,
“is_primary”: true,
“is_group_registration”: false,
“is_going”: true,
“is_checked_in”: false,
“Event”: {
“id”: 133,
“code”: “5-56d9f21b2ec67”,
“name”: “Karl Test”,
“description”: “<p>Test For Karl</p>\n”,
“status”: “secondary/waitlist”,
“limit”: 25,
“group_registrations_allowed”: false,
“group_registrations_max”: 5,
“active”: true,
“member_only”: false,
“virtual_url”: “”,
“call_in_number”: “”,
“phone”: “”,
“metadata”: {
“venue_id”: “0”,
“additional_attendee_reg_info”: “1”,
“add_attendee_question_groups”: {
“1”: “1”
},
“date_submitted”: “2016-03-04 15:37:47”,
“default_payment_status”: “”,
“event_hashtag”: “”,
“event_format”: “”,
“event_livestreamed”: “”,
“”: “”
}
},
“Attendee”: {
“id”: 4498,
“firstname”: “Karl”,
“lastname”: “Sutton”,
“address”: “2005 Sheppard Ave E”,
“address2”: “”,
“city”: “Toronto”,
“state”: “Ontario”,
“country”: “”,
“zip”: “M2J 5B4”,
“email”: “ksutton@mortgagealliance.com”,
“phone”: “1111111111”
},
“Transaction”: {
“id”: 4498,
“timestamp”: “2016-03-04 15:38:51”,
“total”: 0,
“amount_paid”: 0,
“status”: “complete”,
“details”: “”,
“tax_data”: “”,
“session_data”: “”,
“payment_gateway”: “”
},
“Datetime”: {
“id”: 549,
“is_primary”: true,
“event_start”: “2016-03-09 08:00:00”,
“event_end”: “2016-03-09 17:00:00”,
“registration_start”: “2016-03-01 01:00:00”,
“registration_end”: “2016-03-08 04:00:00”,
“limit”: 25,
“tickets_left”: 24
},
“Price”: {
“id”: 739,
“name”: “General Admission”,
“amount”: 0,
“description”: “”,
“limit”: 25,
“remaining”: 24,
“start_date”: null,
“end_date”: null,
“Pricetype”: {
“id”: 1,
“name”: “Base Price”,
“is_member”: false,
“is_discount”: false,
“is_tax”: false,
“is_percent”: false,
“is_global”: true,
“order”: 0
}
}
}
]
}
}

So it seemingly works for that so far?

What else do I need to do?

Thanks.


Tony

  • Support Staff

March 7, 2016 at 2:08 am

It looks like on a previous attempt to POST/PUT a registration onto an event the registration was not assigned to any event.

Notice in this reply, the output shows:

[is_checked_in] => 1\n [Event] => \n [Attendee] => Array\n (\n [id] => 4488\n [firstname]

There’s no event assigned to that registration which is causing the error mentioned.

Also the ID of the registrations seems wrong – 4488.0

Can you view that registration within the admin?


MAC Webmaster

March 10, 2016 at 10:15 pm

In checking the admin interface I can’t see the registration from this posting https://eventespresso.com/topic/json-api-using-get-registrations-returns-500-error/#post-192846 should I try and take the example from this posting (https://eventespresso.com/topic/json-api-using-get-registrations-returns-500-error/#post-195336) and use it to attempt to add a registration?


Tony

  • Support Staff

March 11, 2016 at 3:10 am

should I try and take the example from this posting (https://eventespresso.com/topic/json-api-using-get-registrations-returns-500-error/#post-195336) and use it to attempt to add a registration?

If by that you mean try to add a registration to that event, you could yes. However make sure you format the registration correctly and assign it to an event but you push it.

Basically it sounds like when you first tried to add a registration using the API you did not provide an event for the registration, the API is pulling the registration but doesn’t know what event it should be for and throws an error. Event Espresso itself will not create registrations that are not assigned to an event, which is why the registrations display fine when you view the registrations for the new test event.

Before going any further I highly recommend creating a database backup.

You will likely need to remove that registration from the database (or assign it to an the event it was intended for) for the registrations endpoint to work correctly again. Take a look within the {prefix}_events_attendee table (likely wp_events_attendee) and see if you can find a registration with the ID 4488.0

Compare it with another registration and follow the format to fix it, or simply remove that row an see if the registrations endpoint works again.

If you are unsure of any of the above I would recommend contacting a developer who can work through this with you, you need be careful when editing your database and always make a backup before making any changes.


MAC Webmaster

March 14, 2016 at 8:16 am

Thanks for the help.

I did as you suggested and removed the previous registration attempts from the db and then retried. It looks like it is not working correctly. I still can’t get a list of all registrations but I needed to be able to create a registration for an event and it looks like I can do that now.

I have one other question. Can I process a payment through paypal using the JSON API?

Thanks again.


Tony

  • Support Staff

March 15, 2016 at 6:45 am

I did as you suggested and removed the previous registration attempts from the db and then retried. It looks like it is not working correctly. I still can’t get a list of all registrations

Are you sure you removed all of the problem registrations?

Can I process a payment through paypal using the JSON API?

I don’t believe you can process any payments within the API but I will check with the developers on this.

Viewing 15 reply threads

The support post ‘JSON API using GET /registrations returns 500 error’ 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