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.
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
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)- A3% (1)
- B79% (23)
- C7% (2)
- D10% (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.
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.
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.
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.
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
Community Discussion
No community discussion yet for this question.
