nerdexam
CiscoCisco

200-901 · Question #397

200-901 Question #397: Real Exam Question with Answer & Explanation

The correct answer is B: Replace -u cisco:cisco parameter with -u 'cisco:cisco'.. Credentials passed to curl's -u flag must be quoted so the shell does not misinterpret the colon or other characters, preventing authentication failures against the RESTCONF API.

Understanding and Using APIs

Question

Refer to the exhibit. An administrator attempts to perform a GET operation by using the Cisco IOS XE RESTCONF API to return the hostname of a device. The sequence diagram in the exhibit illustrates the HTTP messages observed. Which change to the API request resolves the issue?

Options

  • ARemove the -H 'Accept: application/yang-data+json' header.
  • BReplace -u cisco:cisco parameter with -u 'cisco:cisco'.
  • CChange the request method from -X 'GET' to -X 'POST'.
  • DAdd the -H 'Content-Type: application/yang-data+json' header.

Explanation

Credentials passed to curl's -u flag must be quoted so the shell does not misinterpret the colon or other characters, preventing authentication failures against the RESTCONF API.

Common mistakes.

  • A. The 'Accept: application/yang-data+json' header controls the response format negotiated with the server - removing it affects content negotiation, not the authentication failure shown in the sequence diagram.
  • C. GET is the correct HTTP method for retrieving data such as a hostname from a RESTCONF endpoint; changing to POST would attempt resource creation and is semantically incorrect for a read operation.
  • D. The 'Content-Type' header describes the format of a request body sent to the server, which is absent in a GET request; adding it does not affect authentication and would not resolve a 401 error.

Concept tested. RESTCONF API curl authentication credential quoting

Reference. https://developer.cisco.com/docs/ios-xe/restconf/

Topics

#RESTCONF#API Authentication#Curl Syntax#HTTP Headers

Community Discussion

No community discussion yet for this question.

Full 200-901 PracticeBrowse All 200-901 Questions