Complete the code to send a POST request to create a new user.
response = requests.[1]('https://api.example.com/users', json={'name': 'Alice'})
The post method sends data to create a new resource.
Complete the code to check if the POST request was successful.
if response.status_code == [1]: print('User created successfully')
Status code 201 means the resource was created successfully.
Fix the error in the code to send JSON data in the POST request.
response = requests.post('https://api.example.com/users', [1])
data sends form data, not JSON.json.dumps with data sends a string, not JSON.Use the json parameter to send JSON data properly.
Fill both blanks to create a POST request with headers and JSON data.
headers = {'Content-Type': [1]
response = requests.post('https://api.example.com/users', headers=headers, [2]={'name': 'Bob'})data instead of json sends form data.text/plain is incorrect for JSON.Set the Content-Type header to application/json and use the json parameter to send JSON data.
Fill all three blanks to handle the POST response and print the new user's ID.
response = requests.post('https://api.example.com/users', json={'name': 'Carol'}) if response.status_code == [1]: data = response.[2]() print('New user ID:', data[[3]])
response.text instead of response.json().Check for status code 201, parse JSON response with json(), and access the 'id' key.
