nerdexam
Cisco

300-435 · Question #38

Refer to the exhibit. A Python script must be created to deactivate vSmart Policy Cisco SD-WAN vManage Configuration APIs. The documentation states the URL is as shown in the exhibit for the REST…

The correct answer is B. s.post(f"https://vmanage:8443/dataservice/template/policy/vsmart/activate/%s" % policy_id). To deactivate a vSmart Policy using the Cisco SD-WAN vManage API, the policyId must be included as a path parameter in the POST request URL.

Controller-Based Network Automation

Question

Refer to the exhibit. A Python script must be created to deactivate vSmart Policy Cisco SD-WAN vManage Configuration APIs. The documentation states the URL is as shown in the exhibit for the REST CALL using POST, and that "policyId" is a required request parameter. Which line of Python code makes this call, assuming the variable "s" is a valid Requests session object and the variable "policy-id" is the policyid?

Exhibit

300-435 question #38 exhibit

Options

How the community answered

(20 responses)
  • A
    5% (1)
  • B
    80% (16)
  • C
    5% (1)
  • D
    10% (2)

Why each option

To deactivate a vSmart Policy using the Cisco SD-WAN vManage API, the `policyId` must be included as a path parameter in the POST request URL.

As.post(f"https://vmanage:8443/dataservice/template/policy/vsmart/activate?policyId=%s" % policy_id)

This option incorrectly sends `policyId` as a query parameter (`?policyId=%s`), whereas the API documentation specifies it as a path parameter.

Bs.post(f"https://vmanage:8443/dataservice/template/policy/vsmart/activate/%s" % policy_id)Correct

The exhibit's URL pattern `.../activate/{policyId}` indicates that `policyId` is a path parameter, meaning it should be directly embedded into the URL path. Option B correctly uses string formatting `activate/%s" % policy_id` to place the `policy_id` variable directly into the URL path, forming the correct endpoint for the REST call.

Cs.post(f"https://vmanage:8443/dataservice/template/policy/vsmart/activate&policyId=%s" % policy_id)

This option uses an incorrect `&policyId=%s` syntax for a URL parameter and attempts to send `policyId` as a query parameter instead of a path parameter.

Ds.post(f"https://vmanage:8443/dataservice/template/policy/vsmart/activate/", data = {'policyId': policy_id})

This option attempts to send `policyId` in the request body (`data = {{'policyId': policy_id}}`), which is incorrect as the API documentation indicates `policyId` is a path parameter.

Concept tested: REST API path parameters with Python Requests

Source: https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting

Topics

#REST API#Python Requests Library#URL Construction#Cisco SD-WAN vManage

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice