Sending data with requests.post()
Sends a Python dictionary to a web API as a JSON request body, unlike GET which only fetches data. Check the response with response.status_code.
Understanding Sending data with requests.post() in QCE Digital Solutions Unit 4
What it does: POST carries a body of data to the API, while requests.get() only asks for data and does not send a JSON body. A status code of 201 means the new data was created, so comparing status_code with 201 confirms the POST worked. An API normally expects a JSON object, and a Python dictionary is converted into one. A lone number is not a record with named fields. 404 means Not Found, which suggests the URL is wrong. Success codes are in the 200s, such as 200 or 201.
Common mistakes: The library is called requests (with an s). 'import request' raises a ModuleNotFoundError, so requests.post() can never run. It should be 'import requests'. Key-value pairs need a dictionary, which uses curly braces. Square brackets make a list, and a list cannot hold name: value pairs. It should be d = {"name": "Ava", "pts": 9}.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 334–401) and word search (Modules 127–401).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
requests.post(url, json=data)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →