A script loads a JSON list of access points into the variable aps and then evaluates aps["name"]. It throws a type error. Each list item is an object with a name field. What is the mistake?
Select an answer to reveal the explanation.
Short Explanation
aps is a list, and you asked it for a field as if it were one object. Pick an item, then read that item's name. A normal name field is legal JSON, and a 200 does not mean the script should throw.
Full Explanation
A JSON list is indexed by position. Each element can be an object with a name field, and the field is read from the element, not from the list. Evaluating aps["name"] treats the list as a dictionary and throws a type error. Select an item first and the error goes away. The script has to select an item, such as the first element, and then read the name. The name field is ordinary JSON. An access-point object that has it will not throw just because the key exists. Reading a field does not print the length of the list. Printing 3 would be a length operation, which this expression is not. HTTP 200 means the request succeeded. It does not require the script to throw, and the type error happens while indexing the parsed value, after a successful load. Exam caveat: if the payload is a single object rather than a list, indexing ["name"] is correct. The question states a list of objects, so the extra index is required. Operational check: print the type of aps and the name of one element in the lab before you loop the whole inventory.