eventbrite / eventbrite-sdk-php

0 stars 2 forks source link

Unable to retrieve user owned events #7

Closed CaioBianchi closed 5 years ago

CaioBianchi commented 7 years ago

I am unable to pull data from https://www.eventbrite.ca/developer/v3/endpoints/users/#ebapi-get-users-id-owned-events (GET /users/:id/owned_events/)

I currently have a method exactly like this:

    public function get_user_events()
    {
        return $this->client->get_user_owned_events('me');
    }

But I get a 400 error:

status_code => integer 400
error_description => string (54) "You passed a request body that was not in JSON format."
error => string (12) "INVALID_BODY"

Any ideas?

mauriciogior commented 7 years ago

@CaioBianchi In HttpClient#47 there is a bug.

Replace this:

   $options = array(
        'http'=>array(
            'method'=>$httpMethod,
            'header'=>"content-type: application/json\r\n",
            'content'=>$data,
            'ignore_errors'=>true
        )
    );

With this:

    $options = array(
        'http'=>array(
            'method'=>$httpMethod,
            'header'=>"content-type: application/json\r\n",
            'ignore_errors'=>true
        )
    );

    if ($httpMethod == 'POST') {
        $options['http']['content'] = $data;
    }
CaioBianchi commented 7 years ago

Good catch, @mauriciogior Let's wait and hope that your PR gets merged. :)

mayoalexander commented 7 years ago

Need this fix!

dgudema commented 6 years ago

That fix does not work for me. I am getting the same "You passed a request body that was not in JSON format." and I made the fix. I believe I am going to have to leave the API and do a PHP Curl directly to make this publish endpoint work with this API. Obviously it works in the https://www.eventbriteapi.com/v3/ testing tool, so something is wrong in this API code. It is broken. Let me know if anybody has an answer. Of if curl works as a work around, will show it here.

mhall-cwd commented 5 years ago

I was trying $client->get_user_events('me') which resulted in the same error. The fix above didn't work. What did work was changing $data = json_encode($body); to $data = empty($body) ? '{}' : json_encode($body); in public function request($path, $body, $expand, $httpMethod = 'GET') in the HttpClient.php file.

zetahernandez commented 5 years ago

solved #17