Answer-check requires a status code 503

Screen Link:

I can’t pass the answer-check, since it requires the status is 503 instead of 200. Is this correct?

How can I create a 503 status to pass this screen?

Thanks for the help:)

library(httr)
base <- 'https://x-math.herokuapp.com'
endpoint <- 'api/random'
url <- modify_url(base, path = endpoint)
queries <- list(max=500, minFirst=100)

response <- GET(url, queries)
status <- status_code(response)
content <- content(response) 
1 Like

I did

status <- as.integer(503)

to pass the answer-check…

But I am not sure if this `503 is on purpose or where I can report it…Hope here is the right place.

1 Like

Yeah, that’s quite odd.

503 is normally for application error or unavailable API or endpoint. 200 is when the GET call is successful.

Could you please share your feedback with the Content & Product teams of Dataquest? Just click the ? button in the upper-right corner of any screen of the Dataquest learning platform, select Share Feedback, fill in the form, and send it. Thanks!

2 Likes

Thanks:) I will do that.

1 Like

On another note, your query is not exactly correct.

What’s important to note is the API is not for generating random numbers from min to max. Rather, it is to generate an expression that uses two randomly generated numbers that also includes a mathematical operator.

Based on the instruction:

Search the API documentati onto determine the endpoint for a random product of two-digit numbers.

If I understand it correctly, you’re trying make a GET request to the following: https://x-math.herokuapp.com/api/random?max=500&minFirst=100.

The above won’t give you a product of two-digit numbers.api/random will give you a random operator. It could be +, -, *, or /. Which means you’ll not get a product of two numbers all the time.To get the product of two numbers you’ll need to use api/mul.

But that’s not enough. Next step is to only use numbers from 10 - 99 which are two-digit numbers.

In your code, even if we change it to a mul, it still won’t be correct because there are all going to be 3 digit numbers. Essentially, the results from yours could randomly be:

  • 443 * 412
  • 394 * 131
  • 270 * 266

You can test the above here. The full url would be https://x-math.herokuapp.com/api/mul?max=500&minFirst=100.

Actually: you can just access the whole link with a browser and see the results: https://x-math.herokuapp.com/api/mul?max=500&minFirst=100. Just reload to get a different result.

What the question actually requires is something like (10 to 99) * (10 to 99) which you can get with https://x-math.herokuapp.com/api/mul?max=99&min=10.

Feel free to ask questions if you have some.

2 Likes

@wanzulfikri , you are really nice!
I am aware of that, just trying to explore the API since it is new for me.
I have tried the url directly in the browser to check if the command line will give me the same result.

I have reported the answer-check issue through feedback.

Thanks for your time and elaboration, really appreciate it:)

2 Likes

Ah, I see. I’m sorry for assuming you aren’t aware of that.

Oh well, I’ll leave the answer up in case anyone needs some help answering the challenge.

And thanks a bunch for sharing the feedback. It will definitely help other learners in the future.

You are really nice as well, @ClarkShi. Thank you for being a part of the community. I really appreciate it.

2 Likes