Support

Home Forums Event Espresso Premium JSON API Add-on Error Code 500

JSON API Add-on Error Code 500

Posted: September 14, 2015 at 7:29 am

Viewing 1 reply thread


Doug Staneart

September 14, 2015 at 7:29 am

We have activated the “Espresso JSON API Add-on” plugin in http://www.fearlesspresentations.com/ website.
After that we call api from the http://maketickdemo.com/leadersinstitute/ website. Below is the sample code for fetching the upcoming event from the fearlesspresentations website.

<?php
$curdate = date(“Y-m-d H:i:s”);
$ch = curl_init();
$url = “http://www.fearlesspresentations.com/espresso-api/v1/authenticate/&#8221;;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$args = array(‘username’=>’*****’, ‘password’ => ‘*******’);
if(!empty($args) )
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
}
$result = curl_exec($ch);
curl_close($ch);
$token = json_decode($result, true);

if(isset($token[‘status’]) && $token[‘status’] == ‘OK’){
$ch = curl_init();
$url1 = “http://www.fearlesspresentations.com/espresso-api/v1/events/&#8221;.$token[‘body’][‘session_key’].”.json/”;

curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$args = array(‘Datetime.event_start__gt’=>urlencode($curdate), ‘limit’ => 2);
if(!empty($args) )
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
}
$result1 = curl_exec($ch);
curl_close($ch);
$data = json_decode($result1, true);
echo “

"; print_r($data);echo "

“;
}
?>

After implementing the coding we are getting this status.

Arrey
{
[status] => Endpoint not yet implemented
[status_code] => 500
}


Josh

  • Support Staff

September 14, 2015 at 1:41 pm

Hi Doug,

It looks like it’s this part that’s throwing things off:

$args = array(‘Datetime.event_start__gt’=>urlencode($curdate), ‘limit’ => 2);
if(!empty($args) )
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
}

Can you try removing the above, then adding the parameters as querystring variables like this?

$args = '?Datetime.event_start__gt='.urlencode($curdate).'&limit=2';
$url1 = "http://www.fearlesspresentations.com/espresso-api/v1/events/".$token['body']['session_key']."/".$args;
Viewing 1 reply thread

The support post ‘JSON API Add-on Error Code 500’ 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