nerdexam
Cisco

300-435 · Question #14

A developer is writing an application that uses a REST API and the application requires a valid response from the API. Which element of the response is used in the conditional check?

The correct answer is B. Status code. To determine if a REST API call received a valid response, the HTTP status code is the primary element used in conditional checks, as it explicitly indicates the success or failure of the request.

Network Automation Foundation

Question

A developer is writing an application that uses a REST API and the application requires a valid response from the API. Which element of the response is used in the conditional check?

Exhibit

300-435 question #14 exhibit

Options

  • AURL
  • BStatus code
  • CLink
  • DBody
  • EHeaders

How the community answered

(42 responses)
  • A
    2% (1)
  • B
    86% (36)
  • C
    7% (3)
  • D
    5% (2)

Why each option

To determine if a REST API call received a valid response, the HTTP status code is the primary element used in conditional checks, as it explicitly indicates the success or failure of the request.

AURL

The URL is part of the request, not the response, and is not used to check the validity of the API response itself.

BStatus codeCorrect

The HTTP status code (e.g., 200 OK, 201 Created, 404 Not Found, 500 Internal Server Error) is the standard and most reliable element in a REST API response to determine the success or failure of a request. Developers use conditional checks on these codes to guide application logic and handle various outcomes.

CLink

Links (often found in the response body or headers for HATEOAS) provide navigation to related resources but do not, by themselves, indicate the validity or success of the current request.

DBody

The response body contains the data returned by the API but does not inherently signal the success or failure of the operation; a successful request might return an empty body, and an error might return an error message in the body.

EHeaders

Headers contain metadata about the response (e.g., content type, caching instructions) but the primary indicator of the request's success or failure is the status code.

Concept tested: REST API response status codes

Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

Topics

#REST API#HTTP Response#API Development#Conditional Logic

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice