Reputation: 1
I get a "400 Bad Request" and "Did you forget the body variable?" Code:
require "rest-client"
require "json"
# This is the ID that you copied down in the last exercise
your_folder_id = "816582409"
# Add the "body" variable here
body = { "description" => "I made this on Codecademy!"
}
response = RestClient.put(
"https://api.box.com/2.0/folders/#{816582409}",
JSON.generate(body),
:authorization => "Bearer" << "AKGEp7MoDfLAKnMyxTt3nSNtohXW3bt1"
)
JSON.parse(response.body)["description"]
Upvotes: 0
Views: 92
Reputation: 26979
"https://api.box.com/2.0/folders/#{816582409}"
evaluates to "https://api.box.com/2.0/folders/"
due to string interpolation. As ararog suggests, put the variable itself in: #{@your_folder_id}
or the plain number, not #{816582409}
Upvotes: 0
Reputation: 1092
The url of api call shouldn't be https://api.box.com/2.0/folders/816582409
or "https://api.box.com/2.0/folders/#{@your_folder_id}"
?
Upvotes: 1
Reputation: 6258
You are missing a space between Bearer and nonsense. You have something like:
response = RestClient.put(
"https://api.box.com/2.0/folders/#{816582409}",
JSON.generate(body),
:authorization => "Bearer " << "AKGEp7MoDfLAKnMyxTt3nSNtohXW3bt1"
)
Upvotes: 0