exam questions

Exam 350-901 All Questions

View all questions & answers for the 350-901 exam

Exam 350-901 topic 1 question 114 discussion

Actual exam question from Cisco's 350-901
Question #: 114
Topic #: 1
[All 350-901 Questions]


Refer to the exhibit. A developer must create a new network object named testnetwork by using the Cisco Firepower Device Management API. The script must also handle any exceptions that occur during the request and print out any resulting errors.
Which script must be used?
A.

B.

C.

D.

Show Suggested Answer Hide Answer
Suggested Answer: A

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
tommiy
Highly Voted 2 years, 8 months ago
The question is testing the understanding of the use of requests and the passing of form and json data to the requests module. In all options the headers are indicating that the accepted format is json data. The data variable is a python dict and if passed to data is treated as a form encoded data. to pass the contents of the dict as json you need to use json.dumps(data). More detail from reading the requests module documentation with similar example. https://docs.python-requests.org/en/master/user/quickstart/#more-complicated-post-requests.
upvoted 12 times
...
Kiwi2
Highly Voted 2 years, 5 months ago
D is the correct answer. Very good example on the following link: https://github.com/CiscoDevNet/fmc-rest-api/blob/master/labs/firepower-restapi-106/4.md
upvoted 11 times
...
al_mon
Most Recent 3 months, 1 week ago
B, in A headers=headers is missing, and rise.for.status
upvoted 1 times
...
VincentVega
7 months, 3 weeks ago
D is correct! B and D looks the same... but type is different so why json.dumps should be used. import json data={"param_1":"value_1","param_2":"value_2"} print(data,type(data)) print(json.dumps(data),type(json.dumps(data))) {'param_1': 'value_1', 'param_2': 'value_2'} <class 'dict'> {"param_1": "value_1", "param_2": "value_2"} <class 'str'>
upvoted 2 times
...
NetGirl
1 year, 7 months ago
D is correct. With Content-Type: Application/json, you have two choices to insert data in the request: data = json.dump(data) >> the data in parenthesis is the name of the dictionary variable or json = data >> again, data is the name of our dictionary
upvoted 3 times
...
designated
1 year, 8 months ago
B and D are correct
upvoted 1 times
...
QuiShong
1 year, 11 months ago
I'd go with D, as it is more correct. The server may understand form-encoded data (in the case of B), but it isn't guaranteed. https://stackoverflow.com/questions/47188244/python-requests-library-data-vs-json-named-arguments-with-requests-post
upvoted 1 times
...
CiscoRider
1 year, 11 months ago
If you think about it, but Headers and Data are Json information. Because in both options, Header is pointing to the variable, I would expect to handle the same with the Data variable. That plus SSSSSS confirmed it works without the dump option.
upvoted 1 times
...
__al__
2 years, 1 month ago
This is a terrible question. Both B and D are correct. This question probably dates back from when you had to use json.dumps() on a dict containing your POST data. This is not necessary for a considerable time already. So I'm hoping this question does not come in my test, of at least that it has been updated recently, because as of today it is simply broken.
upvoted 2 times
...
duracell
2 years, 4 months ago
D is correct. See section "Function create one host object" https://cyruslab.net/2020/02/27/pythoncisco-fmc-rest-api-example-get-server-version-and-add-device-to-cisco-fmc/
upvoted 3 times
...
bpbenabd
2 years, 5 months ago
B is the correct answer.
upvoted 2 times
__al__
2 years, 2 months ago
I am inclined to go with B. requests lib is smart enough to treat a python dict as json.
upvoted 1 times
...
...
arturogonzalezgzz
2 years, 7 months ago
The answer is D... json.dumps it's very important to send the message... The data you create on python it's on dictionary structure use for Python.. when you send to an API and you confirm in your header Json structure, you need to parse it to Json.
upvoted 1 times
Boris31
2 years, 5 months ago
Correct answer: B No json.dumps() according below ressource: https://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests
upvoted 3 times
SSSSSS
2 years, 5 months ago
Agree with Boris31, I was able to post without json.dumps on my PoC env.
upvoted 1 times
...
digix
2 years, 5 months ago
I think D is correct. B would be correct if they use the syntax with json=data instead of data=data
upvoted 2 times
__al__
2 years, 1 month ago
No... data=data works just fine.
upvoted 1 times
...
...
...
...
jjkcoins
2 years, 8 months ago
A is wrong due to missing headers argument C is wrong due to swapped data and headers variables B or D could be right. All 4 options don't define error. I'm assuming the test with have 'except Exception as error:' before print(error) vs 'except:'
upvoted 2 times
__al__
2 years, 2 months ago
if you do not explicit anything after 'except', python will treat it as 'except Exception' anyways.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago