Go to Post Possibly the most amazing thing all week was that this game can be played with mecanum wheels. - fargus111111111 [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
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 28-05-2016, 12:33
dirtbikerxz's Avatar
dirtbikerxz dirtbikerxz is offline
Captain | Driver | CAD | Junior
AKA: Rohit Gondi
FRC #3991 (KnightVision)
Team Role: Driver
 
Join Date: Nov 2014
Rookie Year: 2015
Location: Baton Rouge, LA
Posts: 480
dirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud of
Need help with X-TBA-App-Id Header for TBA API

What exactly am I supposed to put in the header when requesting?

For the FRC Events API V2.0 the header I use is
"Authentication: Basic *my auth key*"

What do I use for the TBA API Header? I have tried
"frc3991:scouting-system:v01"
and
"X-TBA-App-Id: frc3991:scouting-system:v01"

Neither have worked, I'm prob just missing something simple . Thanks for the help.
__________________

Team 3991: Driver since freshman (2015-), Captain since sophomore (2016-), CADer
"The human condition is not perfect. We are not perfect specimens, any of us. We're not robots." - Michael Ovitz
My posts may or may not reflect the views of my team, they are my opinions, and mine alone.
Reply With Quote
  #2   Spotlight this post!  
Unread 28-05-2016, 12:56
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 265
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Need help with X-TBA-App-Id Header for TBA API

What you have should work just fine. Are you sure you're making the request with that header? If you're using a Web request function in a programming language, usually you have to set headers by name (something.setHeader("X-TBA-App-Id", "my:app:id") )
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #3   Spotlight this post!  
Unread 28-05-2016, 13:09
dirtbikerxz's Avatar
dirtbikerxz dirtbikerxz is offline
Captain | Driver | CAD | Junior
AKA: Rohit Gondi
FRC #3991 (KnightVision)
Team Role: Driver
 
Join Date: Nov 2014
Rookie Year: 2015
Location: Baton Rouge, LA
Posts: 480
dirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud of
Re: Need help with X-TBA-App-Id Header for TBA API

this is probably very inneficient but for the FRC API i used a php method I found online

Code:
<?php
$opts = array(

  'http'=>array(

    'method'=>"GET",

    'header'=>"Authorization: Basic *My Auth Key*"

	)
);

$context = stream_context_create($opts);



$apiurl = "https://frc-api.firstinspires.org/v2.0/2016/matches/TXHO?tournamentLevel=qual&matchNumber=*";

$file = file_get_contents($apiurl, false, $context);
echo $file;
?>
That works so I tried to do the same thing with the TBA Api

Code:
<?php

$opts = array(

  'http'=>array(

    'method'=>"GET",

    'header'=>"X-TBA-App-Id: frc3991:scouting-system:v01"

	)
);

$context = stream_context_create($opts);

$apiurl = "www.thebluealliance.com/api/v2/team/frc3991/2016/events";
$file = file_get_contents($apiurl, false, $context);

echo $file;

?>
but I get nothing back... (also tried only frc3991:scouting-system:v01 without the X-TBA-App-Id: portion in the header, didn't work)
__________________

Team 3991: Driver since freshman (2015-), Captain since sophomore (2016-), CADer
"The human condition is not perfect. We are not perfect specimens, any of us. We're not robots." - Michael Ovitz
My posts may or may not reflect the views of my team, they are my opinions, and mine alone.
Reply With Quote
  #4   Spotlight this post!  
Unread 28-05-2016, 13:19
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 265
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Need help with X-TBA-App-Id Header for TBA API

Quote:
Originally Posted by dirtbikerxz View Post
this is probably very inneficient but for the FRC API i used a php method I found online

but I get nothing back... (also tried only frc3991:scouting-system:v01 without the X-TBA-App-Id: portion in the header, didn't work)
Do you get nothing back, or a JSON-ified error message?
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #5   Spotlight this post!  
Unread 28-05-2016, 13:20
Michael Hill's Avatar
Michael Hill Michael Hill is offline
Registered User
FRC #3138 (Innovators Robotics)
Team Role: Mentor
 
Join Date: Jul 2004
Rookie Year: 2003
Location: Dayton, OH
Posts: 1,580
Michael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond repute
Re: Need help with X-TBA-App-Id Header for TBA API

Something changed recently (not sure what), but sometimes you may have to send a User-Agent header string as well.
Reply With Quote
  #6   Spotlight this post!  
Unread 28-05-2016, 13:52
dirtbikerxz's Avatar
dirtbikerxz dirtbikerxz is offline
Captain | Driver | CAD | Junior
AKA: Rohit Gondi
FRC #3991 (KnightVision)
Team Role: Driver
 
Join Date: Nov 2014
Rookie Year: 2015
Location: Baton Rouge, LA
Posts: 480
dirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud of
Re: Need help with X-TBA-App-Id Header for TBA API

Oh hell, i forgot to http:// in fornt of the url, the code was searching for the site locally without it, thanks for the help guys

Code that works if anyone cares:

Code:
<?php

$opts = array(

  'http'=>array(

    'method'=>"GET",

    'header'=>"X-TBA-App-Id: frc3991:scouting-system:v01"

	)
);

$context = stream_context_create($opts);

$apiurl = "http://www.thebluealliance.com/api/v2/team/frc3991/2016/events";

$file = file_get_contents($apiurl, false, $context);

echo $file;

?>
__________________

Team 3991: Driver since freshman (2015-), Captain since sophomore (2016-), CADer
"The human condition is not perfect. We are not perfect specimens, any of us. We're not robots." - Michael Ovitz
My posts may or may not reflect the views of my team, they are my opinions, and mine alone.
Reply With Quote
  #7   Spotlight this post!  
Unread 28-05-2016, 14:00
synth3tk's Avatar
synth3tk synth3tk is offline
Volunteer / The Blue Alliance
AKA: David Thomas
no team
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Ohio
Posts: 2,005
synth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond repute
Re: Need help with X-TBA-App-Id Header for TBA API

That's a very... "PHP" way of handling a lack of protocol, lol! Glad you got it all figured out.
__________________
Quote:
The difference between theory and application is that in theory, theory and application are the same; In application, they are not.
Reply With Quote
  #8   Spotlight this post!  
Unread 28-05-2016, 14:12
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
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: Need help with X-TBA-App-Id Header for TBA API

Quote:
Originally Posted by Michael Hill View Post
Something changed recently (not sure what), but sometimes you may have to send a User-Agent header string as well.
I'm pretty sure this is caused by CloudFlare somehow (it's DDON protection might automatically stop requests that come from scripts). It's difficult to trace because it only seems to happen sometimes.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #9   Spotlight this post!  
Unread 28-05-2016, 18:48
Cabey4 Cabey4 is offline
Vision/Scouting/Strategy/Too much
AKA: Tom Schwarz
no team
Team Role: Programmer
 
Join Date: May 2015
Rookie Year: 2015
Location: Sydney
Posts: 26
Cabey4 is on a distinguished road
Re: Need help with X-TBA-App-Id Header for TBA API

Hi, I had this same problem a while ago, where it would give me error 403, forbidden.

I found that I had to add a header called 'User-Agent' with "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11)Gecko/20071127 Firefox/2.0.0.11" to make it think it was a web browser and wouldn't get blocked.

My code for my (python) thingy is https://github.com/Cabey4/4613-Auto-Scout
but it looks like you've already sorted it. But if anyone else gets a 403 forbidden error with the TBA/The Blue Alliance api that's probably why.
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 28-05-2016, 19:04
jtrv's Avatar
jtrv jtrv is offline
github.com/jhtervay
AKA: Justin
FRC #2791 (Shaker Robotics)
Team Role: College Student
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Latham, NY
Posts: 148
jtrv is a name known to alljtrv is a name known to alljtrv is a name known to alljtrv is a name known to alljtrv is a name known to alljtrv is a name known to all
Re: Need help with X-TBA-App-Id Header for TBA API

Quote:
Originally Posted by Cabey4 View Post
Hi, I had this same problem a while ago, where it would give me error 403, forbidden.

I found that I had to add a header called 'User-Agent' with "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11)Gecko/20071127 Firefox/2.0.0.11" to make it think it was a web browser and wouldn't get blocked.

My code for my (python) thingy is https://github.com/Cabey4/4613-Auto-Scout
but it looks like you've already sorted it. But if anyone else gets a 403 forbidden error with the TBA/The Blue Alliance api that's probably why.
You can make things a hell of a lot simpler with the requests library. Just make sure you do
Code:
pip install requests
to install it and suddenly you've made everything loads easier (example).
__________________
2791 (2012-2017)
Reply With Quote
  #11   Spotlight this post!  
Unread 29-05-2016, 11:53
maths222 maths222 is offline
FTC FTA
AKA: Jacob Burroughs
no team
 
Join Date: Nov 2011
Rookie Year: 2010
Location: United States
Posts: 148
maths222 is a splendid one to beholdmaths222 is a splendid one to beholdmaths222 is a splendid one to beholdmaths222 is a splendid one to beholdmaths222 is a splendid one to beholdmaths222 is a splendid one to beholdmaths222 is a splendid one to behold
Re: Need help with X-TBA-App-Id Header for TBA API

Quote:
Originally Posted by synth3tk View Post
That's a very... "PHP" way of handling a lack of protocol, lol! Glad you got it all figured out.
Really, it is the fact that PHP even lets you use "file_get_contents()" to make HTTP requests. "file_get_contents()" is better suited for local files, and CURL or something more elegant that probably wraps CURL for remote HTTP requests.
__________________
--Jacob
Illinois FTC FTA
Reply With Quote
  #12   Spotlight this post!  
Unread 29-05-2016, 14:12
synth3tk's Avatar
synth3tk synth3tk is offline
Volunteer / The Blue Alliance
AKA: David Thomas
no team
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Ohio
Posts: 2,005
synth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond repute
Re: Need help with X-TBA-App-Id Header for TBA API

Quote:
Originally Posted by maths222 View Post
Really, it is the fact that PHP even lets you use "file_get_contents()" to make HTTP requests. "file_get_contents()" is better suited for local files, and CURL or something more elegant that probably wraps CURL for remote HTTP requests.
I didn't even catch that, thanks. I'm assuming that they have some reason for using file_get_contents. If not, OP, you should look into CURL.
__________________
Quote:
The difference between theory and application is that in theory, theory and application are the same; In application, they are not.
Reply With Quote
  #13   Spotlight this post!  
Unread 29-05-2016, 14:16
dirtbikerxz's Avatar
dirtbikerxz dirtbikerxz is offline
Captain | Driver | CAD | Junior
AKA: Rohit Gondi
FRC #3991 (KnightVision)
Team Role: Driver
 
Join Date: Nov 2014
Rookie Year: 2015
Location: Baton Rouge, LA
Posts: 480
dirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud ofdirtbikerxz has much to be proud of
Re: Need help with X-TBA-App-Id Header for TBA API

Quote:
Originally Posted by synth3tk View Post
I didn't even catch that, thanks. I'm assuming that they have some reason for using file_get_contents. If not, OP, you should look into CURL.
Ya, I was only using file_get_contents because I already knew how, but I will look into CURL thanks!
__________________

Team 3991: Driver since freshman (2015-), Captain since sophomore (2016-), CADer
"The human condition is not perfect. We are not perfect specimens, any of us. We're not robots." - Michael Ovitz
My posts may or may not reflect the views of my team, they are my opinions, and mine alone.
Reply With Quote
  #14   Spotlight this post!  
Unread 29-05-2016, 14:52
Oscar Lewis's Avatar
Oscar Lewis Oscar Lewis is offline
Registered User
FRC #2557 (SOTABots)
Team Role: Alumni
 
Join Date: May 2016
Rookie Year: 2012
Location: Seattle, Washington
Posts: 2
Oscar Lewis is on a distinguished road
Re: Need help with X-TBA-App-Id Header for TBA API

I am also currently using file_get_contents() mostly because I am only ever fetching a JSON array once (and it's only needed to set up a MySQL database once per event for scouting) but how I am forming it is
Code:
$jsonurl = "http://www.thebluealliance.com/api/v2/event/$eventcode/teams?X-TBA-App-Id=frc2557:pnwscout:v01"

or in your case

$jsonurl = "http://www.thebluealliance.com/api/v2/team/frc3991/2016/events?X-TBA-App-Id=frc3991:scouting-system:v01
Glad you got it all sorted out!
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 01:07.

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


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