300-835 · Question #49
Refer to the exhibit. Which code snippet must be added to the blank in the script to create a new Cisco Webex space? import requests import json url = 'https://api.ciscospark.com/v1/rooms' access_toke
The correct answer is D. response = requests.post( url, headers={'Authorization': 'Bearer ' + access_token, 'Content-type': 'application/json;charset=UTF-8'}, data = json.dumps({'title': room_title}) ). Option D is correct because creating a new resource via a REST API requires the POST HTTP method, and authentication must use the access_token - the credential that authorizes direct API calls - concatenated properly after 'Bearer '. A is wrong because it uses refresh_token inste
Question
Options
- Aresponse = requests.post( url, headers={'Authorization': 'Bearer ' + refresh_token, 'Content-type': 'application/json;charset=UTF-8'}, data = json.dumps({'title': room_title}) )
- Bresponse = requests.put( url, headers={'Authorization': 'Bearer ' + access_token, 'Content-type': 'application/json;charset=UTF-8'}, data = json.dumps({'title': room_title}) )
- Cresponse = requests.post( url, headers={'Authorization': 'Bearer ', 'Content-type': 'application/json;charset=UTF-8'}, data = json.dumps({'title': room_title}) )
- Dresponse = requests.post( url, headers={'Authorization': 'Bearer ' + access_token, 'Content-type': 'application/json;charset=UTF-8'}, data = json.dumps({'title': room_title}) )
How the community answered
(25 responses)- A8% (2)
- B4% (1)
- C16% (4)
- D72% (18)
Explanation
Option D is correct because creating a new resource via a REST API requires the POST HTTP method, and authentication must use the access_token - the credential that authorizes direct API calls - concatenated properly after 'Bearer '.
- A is wrong because it uses
refresh_tokeninstead ofaccess_token. A refresh token is used only to obtain a new access token via the OAuth flow, not to authenticate API requests directly. - B is wrong because it uses
requests.put, which is for updating an existing resource, not creating a new one. - C is wrong because the
Authorizationheader ends with just'Bearer '- the access token is never appended, so the request would fail authentication entirely.
Memory tip: Think POST = Create, PUT = Update, and remember that the access_token is your "ID badge" to enter the building - the refresh_token is only used at the front desk to get a new badge when yours expires.
Topics
Community Discussion
No community discussion yet for this question.