1

I am trying to make a request to the Eventbrite API. I can successfully make a call from Postman (chrome extension similar to fiddler)

url: https://www.eventbriteapi.com/v3/users/me/owned_events

Header: authentication : Bearer Y5R3SQRPRZBULIHYQHTD

This successfully gets back what I'm looking for. When I try to make the same call through AngularJS

function getLiveEvents() {
    return $http.get(url, {
        cache: true,
        headers: {
            'Authorization': 'Bearer Y5R3SQRPRZBULIHYQHTD',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Accept': '*/*',
        }
    }).then(function (response) {
        return response.data;
    });
}

I always get the error XMLHttpRequest cannot load https://www.eventbriteapi.com/v3/users/me/owned_events?status=live. The request was redirected to 'https://www.eventbriteapi.com/v3/users/me/owned_events/?status=live', which is disallowed for cross-origin requests that require preflight.

Is there something I can do with my AngularJS request so that it will be successful?

FYI: The access-token is real, I'm not concerned about someone using it because it's just a test account.

Phil
  • 157,677
  • 23
  • 242
  • 245
Jon Harding
  • 4,928
  • 13
  • 51
  • 96
  • 4
    Can you change the URL you're using to `https://www.eventbriteapi.com/v3/users/me/owned_events/?status=live` (note the slash after `owned_events`) so it doesn't redirect? Seems to work for me – Phil Mar 24 '15 at 23:56
  • 1
    YOU HAVE NO IDEA how much time you saved me. I've burned about 4 hours trying to figure the stupid thing out. That solved it! – Jon Harding Mar 24 '15 at 23:59
  • 1
    Well, it was pretty much explained in the error message – Phil Mar 24 '15 at 23:59
  • I think postman followed the redirects where as the browser didn't – Jon Harding Mar 25 '15 at 00:01
  • 1
    It wasn't so much about *following* the redirect. The problem is that the `OPTIONS` request doesn't support redirects as part of the pre-flight. More info here - http://stackoverflow.com/questions/18539403/chrome-cancels-cors-xhr-upon-http-302-redirect – Phil Mar 25 '15 at 00:03

0 Answers0