How POST Request Parameters work? With Breakdown for API Attacks
Japneet Sachdeva
Sr. SDET| Full Stack QA | API & UI Automation | QA Advocate | Top 1% Mentor | Gen AI Enthusiast | Prompt Engineering | Continuous Learning | Writes to 80K+| 32K+ Newsletter
POST request is the parent method for all the other Request types. Hence understanding its implementation and its internal working can benefit your Testing and QA process.
What is POST request?
HTTP POST request is a method used by the web to send data to a server to create or update a resource.
Commonly POST requests are used while filling up new user form data, address information etc.
Post Requests use the data in the request payload, which helps in transferring large amount data easily.
Structure of POST Request
A POST request consists of several key components:
Example: curl 'https://reqres.in/api/users' \ -H 'accept: /' \ -H 'accept-language: en-IN,en-GB;q=0.9,en-US;q=0.8,en;q=0.7' \ -H 'cache-control: no-cache' \ -H 'content-type: application/json' \
--data-raw '{"name":"morpheus","job":"leader"}'
Let's decode the above Request:
Refer this post to get practice APIs & Websites for Test Automation: Link
Different Types Encoding:
1. Application/x-www-form-urlencoded
This is the default encoding type for form data. Each key-value pair is encoded as key=value with pairs separated by "&"
Example:
curl -X POST https://example.com/api/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=user123&password=pass123"
2. Multipart/form-data
This encoding type is used for forms that include file uploads. It splits the form data into parts, each with its own content type
Example:
curl -X POST https://example.com/api/profile-picture \
-H "Content-Type: multipart/form-data" \
领英推荐
-F "image=@/path/to/image.jpg" \
-F "userId=12345" \
-F "description=Profile picture upload"
Note: "image=@/path/to/image.jpg" — The file being uploaded, specified with @ to indicate the file path.
3. Application/json
When working with APIs, JSON is often the preferred format due to its simplicity and readability
Example:
curl -X POST https://example.com/api/register \
-H "Content-Type: application/json" \
-d '{"username":"user123","password":"securepass","email":"[email protected]"}'
Common Security Flaws:
Select * From Table_Name
Can display internal details.
Top Tools for API Testing:
1) Postman
2) Same Old Curl Requests
3) Bruno
-x-x-
Get Access to Specialised E-Books for SDETs: Link
Become a Future SDET Manager using my updated course with Questions/Answers for Interview Prep: Link
Follow for more: Japneet Sachdeva
#japneetsachdeva
FinTech | ex-EdTech | Kashinagari.com
1 个月Very helpful