Go to Post No, we will not call you a "stupid freshman", we attribute your hasty remark due to lack of expirence, but you will gain that in time. - Mr. Ivey [more]
Home
Go Back   Chief Delphi > Other > FIRST-related Organizations > The Blue Alliance
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-12-2015, 11:53 PM
blueyoshi256 blueyoshi256 is offline
Registered User
FRC #2823 (Automatons)
Team Role: Alumni
 
Join Date: Mar 2014
Rookie Year: 2013
Location: St. Paul
Posts: 24
blueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to behold
[TBA]: Trouble getting data off of the Blue Alliance API

Hello. I'm currently a senior with team 2823. I've been trying to use The Blue Alliance to gather statistical data for a school project. My programs had been working, up until today.

Here is the python code I've been working with:
Code:
import urllib2
import json
manyevents=["mnmi","mnmi2","mndu2","mndu"]
for i in range(2013,2016):
    for j in manyevents:
        try:
            question="http://www.thebluealliance.com/api/v2/event/"+str(i)+j+"/stats"
            req=urllib2.Request(question)
            req.add_header('X-TBA-App-Id', 'd-wheezy:matchgrabber:2')
            response=urllib2.urlopen(req)
            hi=response.read()
            print hi
        except urllib2.HTTPError:
            print "event "+str(i)+j+" doesn't exist\n"
The goal was to have it simply print out the result of the API call. It gave me back 403:Forbidden.
I checked my API calls against the example ones on The Blue Alliance. They seemed correct.
Still worried that it was my code, I ran this code
Again, 403.

At this point, I have no idea what is wrong. If you see something, let me know. I do have a theory, but I don't think that it is realistic.

I did some googling to find out if it was possible that my IP was blocked or something. Instead, I stumbled across a thread on the dev group about upgrading to https. It is dated for September 7th, which would explain why my code stopped working suddenly. I don't know much about API calls, but it seems like redirecting them to https could cause problems.
To help test this, I decided to check a scouting app that explicitly used The Blue Alliance API. FRC Krawler explicitly stated that it used the Blue Alliance API here. I downloaded it, and tested it. The app ran fine, but no events were able to be selected for any year (PS: If anybody from Knight Krawler is reading this, your app does not handle a blank event field very well).
I also tested two more popular FRC apps, FRC Spyder, and The Blue Alliance app. Both worked fine.

I'm assuming there is a bug in my code, but I can't find it.
Reply With Quote
  #2   Spotlight this post!  
Unread 09-13-2015, 12:06 AM
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
no team (The Blue Alliance)
Team Role: Engineer
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC
Posts: 1,214
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: [TBA]: Trouble getting data off of the Blue Alliance API

Greg flipped the switch to enable global https this week, so that may be the cause of your trouble. The requests should be redirecting automatically, but I don't remember if python urllib will automatically follow redirects or not. You should update your base url and see if that helps.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
The Blue Alliance | The Blue Alliance for Android | FRC Notebook
Reply With Quote
  #3   Spotlight this post!  
Unread 09-13-2015, 12:42 PM
blueyoshi256 blueyoshi256 is offline
Registered User
FRC #2823 (Automatons)
Team Role: Alumni
 
Join Date: Mar 2014
Rookie Year: 2013
Location: St. Paul
Posts: 24
blueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to beholdblueyoshi256 is a splendid one to behold
Re: [TBA]: Trouble getting data off of the Blue Alliance API

Thanks for the fast response. My dad took a look at it with me in the light of day, and we managed to get it working.
Everything is working on your end. The problem is that the python library I was using (urllib2) did not support ssl. We found one that did (httplib), and lo and behold, we got the data.
I will note that this change has probably broken a lot of existing apps using the api. It isn't hard to fix them (just add ssl), but I would recommend adding some sort of message about it on the top of the api documentation, so that when the developers discover that they are broken, they don't have to hunt as much as me.

Thanks again!
David
Reply With Quote
  #4   Spotlight this post!  
Unread 09-13-2015, 01:12 PM
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
no team (The Blue Alliance)
Team Role: Engineer
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC
Posts: 1,214
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: [TBA]: Trouble getting data off of the Blue Alliance API

Quote:
Originally Posted by blueyoshi256 View Post
Thanks for the fast response. My dad took a look at it with me in the light of day, and we managed to get it working.
Everything is working on your end. The problem is that the python library I was using (urllib2) did not support ssl. We found one that did (httplib), and lo and behold, we got the data.
I will note that this change has probably broken a lot of existing apps using the api. It isn't hard to fix them (just add ssl), but I would recommend adding some sort of message about it on the top of the api documentation, so that when the developers discover that they are broken, they don't have to hunt as much as me.

Thanks again!
David
Thanks for the update on what fixed it for you! I filed an issue to track this so we can make sure that api developers know how to update their apps to https.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
The Blue Alliance | The Blue Alliance for Android | FRC Notebook
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:46 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi