5. Putting it all together


#1

` require "rest-client"
require "json"

events_url = "https://api.box.com/2.0/events"

response = RestClient.get(
events_url,
:params => {:limit => 1},
:authorization => "Bearer " << "ACCESS_TOKEN"
)

JSON.parse(response.body)`

Looking for help on this one. I'm new to API integrations and although I followed the directions, I'm receiving a 401 unauthorized error? Could it be that the Box URL is maybe outdated?


#2

I had this same issue. Has anyone out there successfully completed this part?


#3

Same thing has happened to me - Pretty sure that this is a glitch, and Codecademy just doesn't want to fix it.


#4

Oh -- I changed

:authorization => "Bearer " << "ACCESS_TOKEN"

to:

:authorization >> "Bearer " << "ACCESS_TOKEN"

and it worked. Even though it's a syntax error and the editor even says it, that's how it's supposed to be done apparently.


#5

I noticed that "bearer " had a space in the string; I removed it and that solved the problem for me.


#6

I noticed there was a lot of ways to get to the next lesson but you get errors:
- If you type the full oath_header = {: authorization it will work but get a lot of errors.
- If you remove the space get a 400 error but get the green arrow to next lesson.
- If you put replace => with >> you get a ruby error. and same green arrow.

This part of the lesson needs to be fixed.


#7

This is the solution. remove that space.