EventBrite API - batch requesting ticket_classes for recurring event fails

437 views Asked by At

It looks like the ticket_classes have suddenly been remove from the owned_events in the v3 API (Why?). I have an application that depends on this to collect the number of available tickets for a recurring event. Unfortunately separate api calls to collect the ticket_classes take way too long.

So I've been trying to use a batched request like this, hoping it will be faster:

$data = array(
    array('method' => 'GET', 'relative_url' => 'events/xxxxxxxx79/ticket_classes'),
    array('method' => 'GET', 'relative_url' => 'events/xxxxxxxx91/ticket_classes')
);
$datajson = json_encode($data);

$ch = curl_init('https://www.eventbriteapi.com/v3/batch/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $datajson);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Authorization: Bearer {$authorisationToken}",
    'Content-Type: application/json',
    'Content-Length: ' . strlen($datajson)
));
$result = curl_exec($ch);

But all I get is a:

string(113) "{"status_code": 500, "error_description": "The server encountered an internal error.", "error": "INTERNAL_ERROR"}" 

Can anyone please tell me what's wrong with my code?

1

There are 1 answers

0
YanCh On BEST ANSWER

It's not the first time they change their API without notice. There is a way to get the ticket_classes included in the API response. You have to ask for it using the expand parameter (http://www.eventbrite.com/developer/v3/reference/expansions/)

You can use it like this: /v3/users/me/owned_events/?expand=ticket_classes