nerdexam
Cisco

200-901 · Question #397

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 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?

Exhibit

200-901 question #397 exhibit

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.

How the community answered

(29 responses)
  • A
    3% (1)
  • B
    79% (23)
  • C
    7% (2)
  • D
    10% (3)

Why each option

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.

ARemove the -H 'Accept: application/yang-data+json' header.

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.

BReplace -u cisco:cisco parameter with -u 'cisco:cisco'.Correct

Without single quotes, the shell may parse -u cisco:cisco incorrectly in certain environments, causing malformed credentials to be sent and resulting in a 401 Unauthorized response; wrapping the value in single quotes as -u 'cisco:cisco' forces the shell to pass the string literally to curl, ensuring proper HTTP Basic Authentication with the RESTCONF API.

CChange the request method from -X 'GET' to -X 'POST'.

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.

DAdd the -H 'Content-Type: application/yang-data+json' header.

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

Source: 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 Practice