Complete the code to define the HTTP method used to fetch data from another service.
response = requests.[1]('http://service/api/data')
The GET method is used to retrieve data from another service in REST APIs.
Complete the code to add a JSON payload when sending data to another service.
response = requests.post('http://service/api/data', json=[1])
The 'json' parameter expects a dictionary or object named 'payload' containing the data to send.
Fix the error in the code to correctly check if the response status code indicates success.
if response.status_code == [1]: print('Success')
Status code 200 means the request was successful in HTTP.
Fill both blanks to correctly parse JSON data from the response and access the 'user' field.
data = response.[1]() user = data[2]'user')
Use response.json() to parse JSON data, then use .get('user') to safely access the 'user' field.
Fill all three blanks to build a REST API call with headers, query parameters, and handle the JSON response.
headers = {'Authorization': 'Bearer [1]'}
params = {'id': [2]
response = requests.get('http://service/api/item', headers=headers, params=params)
data = response.[3]()Use the correct token string for Authorization header, pass the item ID as query parameter, and parse response JSON.