200-901 · Question #201
Refer to the exhibit. The documentation outlines how to use credentials for the AMP API. Which script successfully performs an API call using basic authentication? A. B. C. D.
The correct answer is B. import requests amp_client_id = 'albc2c3d4e5f6g7h8i9j0' amp_api_key = 'albc2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6' url = 'https://api.amp.cisco.com/v1/version' request = requests.get(url, auth=(amp_client_id, amp_api_key)) print(request.json()). The Python requests library implements Basic Auth by passing a tuple of (client_id, api_key) to the auth parameter: requests.get(url, auth=(amp_client_id, amp_api_key)). Option A is wrong because it passes a single token string instead of a two-element tuple, which is not valid…
Question
Refer to the exhibit. The documentation outlines how to use credentials for the AMP API. Which script successfully performs an API call using basic authentication? A. B. C. D.
Exhibits
Options
- Aimport requests amp_auth_token = 'albc2c3d4e5f6g7h8i9j0_k1l2m3n4o5p6' url = 'https://api.amp.cisco.com/v1/version' request = requests.get(url, auth=(amp_auth_token)) print(request.json())
- Bimport requests amp_client_id = 'albc2c3d4e5f6g7h8i9j0' amp_api_key = 'albc2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6' url = 'https://api.amp.cisco.com/v1/version' request = requests.get(url, auth=(amp_client_id, amp_api_key)) print(request.json())
- Cimport requests amp_client_id = 'albc2c3d4e5f6g7h8i9j0' amp_api_key = 'albc2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6' url = 'https://api.amp.cisco.com/v1/version' request = requests.get(url), auth=(amp_client_id, amp_api_key)) print(request.json())
- Dimport requests amp_client_id = 'albc2c3d4e5f6g7h8i9j0' amp_login_password = 'l0g1n_p@ssw0rd' url = 'https://api.amp.cisco.com/v1/version' request = requests.get(url, auth=(amp_client_id, amp_login_password)) print(request.json())
How the community answered
(21 responses)- A10% (2)
- B81% (17)
- C5% (1)
- D5% (1)
Explanation
The Python requests library implements Basic Auth by passing a tuple of (client_id, api_key) to the auth parameter: requests.get(url, auth=(amp_client_id, amp_api_key)). Option A is wrong because it passes a single token string instead of a two-element tuple, which is not valid Basic Auth. Option C has a syntax error - there is a mismatched parenthesis closing requests.get(url) before the auth parameter, making it unparseable. Option D uses amp_login_password instead of amp_api_key - the AMP API requires the API key, not a login password.
Topics
Community Discussion
No community discussion yet for this question.




