Complete the code to use the HTTP method that is considered safe and only retrieves data.
response = requests.[1]('https://api.example.com/data')
The GET method is safe because it only retrieves data without changing anything on the server.
Complete the code to use the HTTP method that is unsafe and used to create new data on the server.
response = requests.[1]('https://api.example.com/data', json=payload)
POST is an unsafe method because it creates or changes data on the server.
Fix the error in the code by choosing the correct HTTP method that is safe and used to check headers only.
response = requests.[1]('https://api.example.com/data')
HEAD is a safe method that requests headers only, without the body, and does not change server data.
Fill both blanks to complete the code that uses a safe method and checks if the response status is 200.
response = requests.[1]('https://api.example.com/data') if response.status_code [2] 200: print('Success')
GET is a safe method to retrieve data, and checking if status_code == 200 confirms success.
Fill all three blanks to complete the code that sends data with an unsafe method, checks if the response status is 201, and prints a message.
response = requests.[1]('https://api.example.com/data', json=payload) if response.status_code [2] 201: print('[3]')
POST is unsafe because it creates data. Status 201 means 'Created', so printing that message confirms success.