Back to project
Creating/Adding Request to collection
Common Steps for Every Request
- If you highlight the collection you created, you can see an ellipses icon.
- Click on the ellipses icon, and you will see a menu which has an “add request” option in it. Click on it.
JWT Token API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request for example if you are API is creating a JWT token using the storefront API give the name “create storefront3 jwt token”.
- In the URL window enter this URL http://{{myAzureIP}}/auth/jwt/create and the request type is POST
- In the authorization tab select type as “inherit auth from parent”.
- Switch to the body tab, select the raw option and JSON option
- Enter the username and password as a JSON object.
These credentials are nothing but your superuser credentials, which you created in hop-2 step 6
{ "username": "lourduRohithReddyGali", "password": "Bhasker@123mgit$10" }
- In the tests tab Please add the following code
The first line fetches the response as JSON
The second line adds a collection Variable called “jwt_token”. We left this value empty in the first place because we are going to assign its value dynamically.
const response = pm.response.json();
pm.collectionVariables.set("jwt_token", response.access);
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Get store products API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “Get store products”
- In the URL window enter this URL http://{{myAzureIP}}/store/products and the request type is GET
- In the authorization tab select type as “inherit auth from parent”.
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Get store products for page 2 filtered based on collection ID API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “Get store products for page 2 filtered based on collection ID”
- In the URL window enter this URL http://{{myAzureIP}}/store/products/?collection_id=3&page=2 and the request type is GET
- In the authorization tab select type as “inherit auth from parent”.
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Get store product API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “Get store product”
- In the URL window enter this URL http://{{myAzureIP}}/store/products/905 and the request type is GET
- In the authorization tab select type as “inherit auth from parent”.
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Update products details API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “update products details”
- In the URL window enter this URL http://{{myAzureIP}}/store/products/905 and the request type is PUT
- In the authorization tab select type as “inherit auth from parent”.
- Switch to the body tab, select the raw option and JSON option
- Copy and paste the following object.
{
"id": 905,
"title": "Absolut Citron",
"description": "dapibus dolor vel est donec odio justo sollicitudin ut suscipit a feugiat et eros",
"slug": "-",
"inventory": 32,
"unit_price": 300.000,
"price_with_tax": 97.02000000000001,
"collection": 4,
"images": []
}
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Create a cart API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “Create a cart”
- In the URL window enter this URL http://{{myAzureIP}}/store/carts/ and the request type is POST
- In the authorization tab select type as “inherit auth from parent”.
- In the tests tab Please add the following code
The first line fetches the response as JSON
The second line adds a collection Variable called “cart_id” and its corresponding value which is
const response = pm.response.json();
pm.collectionVariables.set("cart_id", response.id);
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Get the newly created cart API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “Get the newly created cart”
- In the URL window enter this URL http://{{myAzureIP}}/store/carts/{{cart_id}} and the request type is GET
- In the authorization tab select type as “inherit auth from parent”.
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Add items to cart API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “add items to cart”
- In the URL window enter this URL http://{{myAzureIP}}/store/carts/{{cart_id}}/items/ and the request type is PUT
- In the authorization tab select type as “inherit auth from parent”.
- Switch to the body tab, select the raw option and JSON option
- Copy and paste the following object.
{ "product_id": 125, "quantity": 2 }
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Create new order API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “create new order”
- In the URL window enter this URL http://{{myAzureIP}}/store/orders/ and the request type is POST
- In the authorization tab select type as “inherit auth from parent”.
- Switch to the body tab, select the raw option and JSON option
- Copy and paste the following object.
{ "cart_id" : "{{cart_id}}" }
- In the tests tab Please add the following code
The first line fetches the response as JSON
The second line adds a collection Variable called “order_id” and its corresponding value which is fetched from the response.
const response = pm.response.json();
pm.collectionVariables.set("order_id", response.id);
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.
Get the newly created order API
- Do the Common Steps for Every Request step.
- Enter a valid name for the request. Suggested name “get the newly created order”
- In the URL window enter this URL http://{{myAzureIP}}/store/orders/{{order_id}} and the request type is GET
- In the authorization tab select type as “inherit auth from parent”.
- Click on Send.
- As soon as you click send, in the response tab, you should see the output.