Bird
0
0

What will be the HTTP status code returned by this REST API snippet?

medium📝 Predict Output Q13 of 15
Rest API - HTTP Status Codes
What will be the HTTP status code returned by this REST API snippet?
return Response(status=301, headers={'Location': 'https://newsite.com'})
A301 Moved Permanently
B302 Found
C200 OK
D404 Not Found
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the status code in the response

    The code explicitly sets status=301, which means permanent redirect.
  2. Step 2: Check the Location header

    The Location header points to the new URL, confirming redirect behavior.
  3. Final Answer:

    301 Moved Permanently -> Option A
  4. Quick Check:

    Status 301 with Location = permanent redirect [OK]
Quick Trick: Status 301 with Location header means permanent redirect [OK]
Common Mistakes:
  • Assuming 200 OK without checking status
  • Confusing 301 with 302
  • Ignoring Location header

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes