23andMe API Lesson 10. HTTP Status Codes placekitten.status


#1

Experiencing a similar problem to this question: Place-kitten API - Getting a response in console, but the course says that I am not getting a response

However, the answer that worked for me in the aforementioned link for a previous lesson doesn’t work with this lesson.

Question instructions:

Instructions
Call status on placekitten and puts this value so you can see the status code returned by the server. It should be ‘200 OK’!

Answers and console output:
answer 1:

require 'open-uri'

placekitten = open('http://placekitten.com/')

# Add your code below!
print placekitten.status

output:
["200", "OK"]nil

Oops, try again. It looks like you didn’t print 200 to the console using puts.

answer 2:

require 'open-uri'

placekitten = open('http://placekitten.com/')

# Add your code below!
puts placekitten.status

Unknown Error: 200 OK RESULT nil

Oops, try again. It looks like you didn’t print 200 to the console using puts.

answer 3:

require 'open-uri'

placekitten = open('http://placekitten.com/')

# Add your code below!
print placekitten.status[0] + " " + placekitten.status[1]

console same as before.

Any help would be appreciated, thanks!


#2

First of all, post a link to the exercise related to your problem, like this: How to use APIs with Ruby, 10: HTTP Status Codes.

Second, I went ahead and checked a similar exercise to figure out what was wrong, and guess what? It is a SCT mistake since it is the same code below but with different name:

require 'open-uri'

website = open('http://placekitten.com/')

# Add your code below!
puts website.status

Use it and you should be fine :slight_smile:


#3

Thank you, sir!

Great I will be sure to post a link next time.

I have no idea why it is working now but it worked so I am proceeding, yay!


#4

Hello
I have exactly the same problem with the same exercise. I tried your fix but it still isn’t working. Any suggestions?


#5

I am not sure, since the course seems to be buggy or out of maintenance. You can see it isn’t being shown on the Codecademy course catalog.


#6

That is a shame as it had been proving quite useful.