How do I view a query string?
→ Enter the URL that contains the query string, for example: http://localhost:54176/api/ProductCategories?name=darren&age=25
→ Click the params, the query string is stored as a set of key-value teams
→ Select key-value pairs, right-select "encodeURIComponent" to encrypt keys or values
How to use body?
→form-data option, enter form data
→x-www-form-urlencoded options, enter form data, postman automatic encryption
→raw option, enter JSON data
{
"Name": "",
"Username": ""
"Age": 25
}
→binary options, upload pictures, audio, video, etc.
Here are some APIs to test for:
Get/categories
Post/categories
Put/categories/{id}
Get/categories/{id}
Delete/categories/{id}
Post/categories/{id}/products
Get/categories/{id}/products
Delete/categories/{id}/products/{productid}
Get/categories/{id}/products/{productid}
Put/categories/{id}/products/{productid}
GET request test?
→ Click no environment create environment variable
Host:http://localhost
port:8080
→get Request
GET {{Host}}:{{port}}/categories
GET {{HOST}}:{{PORT}}/CATEGORIES/1
GET {{host}}:{{port}}/categories/1/products
POST request test?
Create Cateogory
= = Request
POST {{Host}}:{{port}}/categories
Headers:
Content-type:application/json
Body:
{
"Name": ""
}
= = Response
Status 201 Created
{
"id": "1",
"Name": "",
"Products": []
}
Create product
= = Request
POST {{host}}:{{port}}/categories/1/products
Headers:
Content-type:application/json
Body:
{
"Name": "",
"Features": ["H", "O"]
}
= = Response
Status 201 Created
{
"id": "1",
"Name": "",
"Features": ["H", "O"]
}
put request test?
= = Request
PUT {{HOST}}:{{PORT}}/CATEGORIES/1
Headers:
Content-type:application/json
Body:
{
"Name": ""
}
= = Response
Status OK
{
"Message": ""
}
delet request a test?
= = Request
DELETE {{HOST}}:{{PORT}}/CATEGORIES/1
= = Response
{
"Message": ""
}
Query parameters request string test?
= = Request
GET {{Host}}:{port}/categories/1/products?name=h
= = Response
Status OK
[
{
"id": "1",
"Name": "H",
"Features": ["H",...]
},
{
"id": "1",
"Name": "H",
"Features": ["H",...]
}
]
Verify authorization?
Verify who's problem is resolved. Authorization to solve the problem.
The usual scenario is:
→ Enter user name and password
POST .../auth/login
Headers:
Content-type:application/json
Body:
{
"Login": "",
"Password": ""
}
→ service side return token
Get token in response
→ request A token in the headers again
GET: /categories
Headers:
Token: .....
Content-type:application/json
Postman Testing the Web API