API Testing with Postman
Before you automate an API test, send the request by hand and look at what comes back. This page explains the parts of an HTTP request and response, then uses Postman to send requests, write checks in JavaScript, run a whole collection, and run it again from the command line.
7 min read7 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 13 sources13টি সোর্স · updated Nov 2026আপডেট: Nov 2026
Retry a request: safe or not?রিকোয়েস্ট আবার পাঠানো: নিরাপদ কি না?
Send the same request twice and see which methods leave the server unchanged.একই রিকোয়েস্ট দুবার পাঠান আর দেখুন কোন method সার্ভারকে অপরিবর্তিত রাখে।
You’ll learnআপনি শিখবেন
- What each method is forপ্রতিটা method কীসের জন্য
- What idempotent meansidempotent মানে কী
- Why a POST retry can duplicatePOST আবার পাঠালে কেন দুবার হয়
- Which retries are safeকোন retry নিরাপদ
- How to test a repeated POSTএকই POST দুবার কীভাবে টেস্ট করবেন
What it is
HTTP is the foundation of any data exchange on the Web Source 1সোর্স 1. It is a client-server protocol: the client, usually a web browser, starts each request Source 1সোর্স 1. HTTP is stateless: two requests on the same connection have no link to each other Source 1সোর্স 1.
A request names a method, which says what the request is for Source 2সোর্স 2. The server answers with a status code in one of five classes Source 3সোর্স 3. On this page, API testing means sending these requests yourself and checking the responses, with no user interface in between.
Postman is an API client. You enter the request URL, select the method, and add values such as authorization, parameters, body data, and headers Source 5সোর্স 5. Then you test the response with JavaScript: pm.test defines a test with a name, and pm.expect makes an assertion Source 7সোর্স 7.
Fundamentals teaches how to design the test cases. When the checks work by hand, API Automation with Playwright turns them into code.
সহজ English
HTTP is the base of all data exchange on the Web Source 1সোর্স 1. The client asks and the server answers. The client, usually a browser, starts every request Source 1সোর্স 1. HTTP does not remember: two requests sent on the same connection have no link to each other Source 1সোর্স 1.
Each request has a method that says what it is for Source 2সোর্স 2. Each answer has a status code Source 3সোর্স 3. On this page, API testing means you send requests yourself and check the answers, with no screen in between.
Postman is a tool for sending requests. You type the URL, pick the method, and add things like login details, parameters, a body, and headers Source 5সোর্স 5. Then you write tests for the answer in JavaScript, with pm.test and pm.expect Source 7সোর্স 7.
Fundamentals teaches how to design test cases. API Automation with Playwright turns the checks into code.
বাংলা ব্যাখ্যা
Web-এ যেকোনো data আদান-প্রদানের ভিত্তি হলো HTTP Source 1সোর্স 1। HTTP একটা client-server protocol: প্রতিটা request শুরু করে client, সাধারণত web browser Source 1সোর্স 1। HTTP stateless: একই connection-এ পরপর দুটো request-এর মধ্যে কোনো সম্পর্ক থাকে না Source 1সোর্স 1।
প্রতিটা request-এ একটা method থাকে, যেটা বলে request-টা কীসের জন্য Source 2সোর্স 2। Server পাঁচটা শ্রেণির কোনো একটার status code দিয়ে উত্তর দেয় Source 3সোর্স 3। এই পেজে API testing মানে নিজে request পাঠিয়ে response যাচাই করা, মাঝখানে কোনো user interface ছাড়া।
Postman একটা API client। আপনি request URL লেখেন, method বেছে নেন, আর authorization, parameter, body data ও header যোগ করেন Source 5সোর্স 5। তারপর JavaScript দিয়ে response টেস্ট করেন: pm.test একটা নামসহ টেস্ট তৈরি করে, আর pm.expect assertion করে Source 7সোর্স 7।
Test case কীভাবে ডিজাইন করবেন, তা Fundamentals-এ আছে। হাতে চেকগুলো কাজ করলে API Automation with Playwright সেগুলোকে কোডে নিয়ে যায়।
How it works
The method says what the request is for Source 2সোর্স 2.
| Method | What it does |
|---|---|
GET | Requests a representation of a resource. It should only retrieve data, and it should not contain request content Source 2সোর্স 2. |
POST | Submits an entity to a resource, often with a change of state on the server Source 2সোর্স 2. |
PUT | Replaces all current representations of the resource with the request content Source 2সোর্স 2. |
PATCH | Applies partial modifications to a resource Source 2সোর্স 2. |
DELETE | Deletes the resource Source 2সোর্স 2. |
Some methods are idempotent. A method is idempotent if one request has the same intended effect on the server as several identical requests Source 4সোর্স 4. Safe methods, PUT, and DELETE are idempotent. POST and PATCH are not guaranteed to be Source 4সোর্স 4. A client can safely retry a request that uses an idempotent method Source 4সোর্স 4.
The status code says how it went. There are five classes: informational (100–199), successful (200–299), redirection (300–399), client error (400–499), and server error (500–599) Source 3সোর্স 3. Five codes come up often:
201 Created: the request made a new resource; typical after aPOSTSource 3সোর্স 3.401 Unauthorized: in meaning, unauthenticated. The client must authenticate itself Source 3সোর্স 3.403 Forbidden: the server knows who the client is, but the client has no access rights Source 3সোর্স 3.404 Not Found: the server cannot find the resource Source 3সোর্স 3.500 Internal Server Error: the server met a situation that it does not know how to handle Source 3সোর্স 3.
Parameters and body. Query parameters come after ?, as key-value pairs joined by &, for example ?id=1&type=new Source 6সোর্স 6. A path parameter is a placeholder after :, for example /customer/:id Source 6সোর্স 6. A body can be form data, URL-encoded, raw, or binary Source 6সোর্স 6.
সহজ English
The method says what you want Source 2সোর্স 2:
GETreads something. It should only get data Source 2সোর্স 2.POSTsends something to the server, and often changes data there Source 2সোর্স 2.PUTreplaces the whole thing Source 2সোর্স 2.PATCHchanges a part of it Source 2সোর্স 2.DELETEremoves it Source 2সোর্স 2.
Sending it again. A method is idempotent if the intended effect of one request is the same as the effect of many of the same request Source 4সোর্স 4. Safe methods, PUT, and DELETE are idempotent. POST and PATCH may not be Source 4সোর্স 4. A client can safely send an idempotent request again Source 4সোর্স 4.
The status code says how it went. 200 to 299 means success. 400 to 499 is a client error, and 500 to 599 is a server error Source 3সোর্স 3.
201 Created: something new was made, usually after aPOSTSource 3সোর্স 3.401 Unauthorized: you must prove who you are first Source 3সোর্স 3.403 Forbidden: the server knows who you are, but you may not do this Source 3সোর্স 3.404 Not Found: the server cannot find it Source 3সোর্স 3.500 Internal Server Error: the server hit a problem that it cannot handle Source 3সোর্স 3.
Parameters and body. Query parameters go after ?, like ?id=1&type=new Source 6সোর্স 6. A path parameter sits in the path after :, like /customer/:id Source 6সোর্স 6. The body can be form data, URL-encoded, raw, or binary Source 6সোর্স 6.
বাংলা ব্যাখ্যা
Method বলে request-টা কীসের জন্য Source 2সোর্স 2:
GETকোনো resource চায়। এটা শুধু data আনবে, আর এতে request content থাকা উচিত নয় Source 2সোর্স 2।POSTresource-এ কিছু পাঠায়, প্রায়ই server-এ অবস্থা বদলায় Source 2সোর্স 2।PUTপুরো resource-টা request content দিয়ে বদলে দেয় Source 2সোর্স 2।PATCHresource-এর একটা অংশ বদলায় Source 2সোর্স 2।DELETEresource-টা মুছে দেয় Source 2সোর্স 2।
কিছু method idempotent। একটা request আর একই রকম অনেকগুলো request-এর উদ্দেশ্যমূলক ফল server-এ একই হলে method-টা idempotent Source 4সোর্স 4। Safe method, PUT আর DELETE idempotent। POST আর PATCH idempotent হবেই, এমন নিশ্চয়তা নেই Source 4সোর্স 4। Idempotent method-এর request client নিরাপদে আবার পাঠাতে পারে Source 4সোর্স 4।
Status code বলে কী হলো। পাঁচটা শ্রেণি: informational (100–199), successful (200–299), redirection (300–399), client error (400–499) আর server error (500–599) Source 3সোর্স 3। প্রায়ই দেখা যায় এমন পাঁচটা code:
201 Created: request একটা নতুন resource তৈরি করেছে; সাধারণতPOST-এর পর Source 3সোর্স 3।401 Unauthorized: অর্থের দিক থেকে unauthenticated; client-কে নিজের পরিচয় প্রমাণ করতে হবে Source 3সোর্স 3।403 Forbidden: server জানে client কে, কিন্তু client-এর access-এর অধিকার নেই Source 3সোর্স 3।404 Not Found: server resource-টা খুঁজে পায় না Source 3সোর্স 3।500 Internal Server Error: server এমন অবস্থায় পড়েছে, যেটা সে সামলাতে জানে না Source 3সোর্স 3।
Parameter আর body। Query parameter বসে ?-এর পরে, & দিয়ে জোড়া key-value হিসেবে, যেমন ?id=1&type=new Source 6সোর্স 6। Path parameter হলো path-এর ভেতরে :-এর পরের একটা placeholder, যেমন /customer/:id Source 6সোর্স 6। Body হতে পারে form data, URL-encoded, raw বা binary Source 6সোর্স 6।
Try it
- Send a request. Open a new request in Postman and enter
https://postman-echo.com/get?course=sdet. Select theGETmethod, then click Send Source 13সোর্স 13. The Echo service returns JSON with the details of the request that you sent Source 13সোর্স 13. - Add two tests. You can add tests to a request, a collection, or a folder Source 7সোর্স 7. Add this as the post-response script of the request:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("The query comes back", function () {
const body = pm.response.json();
pm.expect(body.args.course).to.eql("sdet");
});pm.response.to.have.status(200) checks the status code, and pm.response.json() parses the JSON body Source 8সোর্স 8. Tests run after the response arrives, and their output appears in the Test Results tab Source 7সোর্স 7. Send the request again and read the two results.
- Use a variable. Store
https://postman-echo.comin abase_urlvariable, and write the URL as{{base_url}}/get?course=sdetSource 9সোর্স 9. When the URL changes, you change the variable once Source 9সোর্স 9. - Run the collection. Save the request in a collection. The Collection Runner sends the requests of a collection in the order you choose and logs the test results of each request Source 10সোর্স 10. You can also choose the iteration data for a run Source 10সোর্স 10.
- Run it from a terminal. Newman is Postman's command-line collection runner Source 11সোর্স 11. It needs Node.js 16 or later Source 11সোর্স 11. Export the collection as a JSON file, then run:
npm install -g newman
newman run my-collection.jsonNewman will not receive updates or fixes, and Postman asks you to plan the move to the Postman CLI Source 11সোর্স 11. The Postman CLI runs a collection with postman collection run Source 12সোর্স 12.
সহজ English
- Send a request. Open a new request in Postman, type
https://postman-echo.com/get?course=sdet, pickGET, and click Send. The Echo service sends back JSON with the details of your request Source 13সোর্স 13. - Add two tests. Add this as the post-response script of the request Source 7সোর্স 7:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("The query comes back", function () {
const body = pm.response.json();
pm.expect(body.args.course).to.eql("sdet");
});The first test checks the status code. The second reads the JSON body Source 8সোর্স 8. The tests run after the answer arrives, and you see them in the Test Results tab Source 7সোর্স 7. Send the request again and read the results.
- Use a variable. Save
https://postman-echo.comasbase_url, and write the URL as{{base_url}}/get?course=sdet. If the address changes, you change it in one place Source 9সোর্স 9. - Run the collection. Save the request in a collection. The Collection Runner sends the requests of a collection in your order and logs the results Source 10সোর্স 10.
- Run it from a terminal. Newman runs a collection from the command line. It needs Node.js 16 or newer Source 11সোর্স 11. Export the collection as JSON, then run:
npm install -g newman
newman run my-collection.jsonNewman gets no more updates or fixes, and Postman says to plan the move to the Postman CLI Source 11সোর্স 11. There, the command is postman collection run Source 12সোর্স 12.
বাংলা ব্যাখ্যা
- একটা request পাঠান। Postman-এ একটা নতুন request খুলে
https://postman-echo.com/get?course=sdetলিখুন।GETmethod বেছে Send-এ ক্লিক করুন Source 13সোর্স 13। Echo service আপনার পাঠানো request-এর খুঁটিনাটি JSON হিসেবে ফেরত দেয় Source 13সোর্স 13। - দুটো টেস্ট যোগ করুন। Request, collection বা folder-এ টেস্ট যোগ করা যায় Source 7সোর্স 7। Request-এর post-response script হিসেবে এটা লিখুন:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("The query comes back", function () {
const body = pm.response.json();
pm.expect(body.args.course).to.eql("sdet");
});pm.response.to.have.status(200) status code চেক করে, আর pm.response.json() JSON body পড়ে Source 8সোর্স 8। Response আসার পর টেস্টগুলো চলে, আর ফলাফল দেখা যায় Test Results tab-এ Source 7সোর্স 7। Request আবার পাঠিয়ে দুটো ফলাফল দেখুন।
- Variable ব্যবহার করুন।
https://postman-echo.comএকটাbase_urlvariable-এ রাখুন, আর URL লিখুন{{base_url}}/get?course=sdetSource 9সোর্স 9। URL বদলালে শুধু variable-টা একবার বদলাবেন Source 9সোর্স 9। - Collection চালান। Request-টা একটা collection-এ সেভ করুন। Collection Runner আপনার বেছে নেওয়া ক্রমে collection-এর request-গুলো পাঠায়, আর প্রতিটার টেস্টের ফলাফল লিখে রাখে Source 10সোর্স 10। একটা run-এর জন্য iteration data-ও বেছে নেওয়া যায় Source 10সোর্স 10।
- Terminal থেকে চালান। Newman হলো Postman-এর command-line collection runner Source 11সোর্স 11। এর জন্য Node.js 16 বা তার পরের version লাগে Source 11সোর্স 11। Collection-টা JSON file হিসেবে export করে চালান:
npm install -g newman
newman run my-collection.jsonNewman আর কোনো update বা fix পাবে না, আর Postman বলে Postman CLI-তে যাওয়ার পরিকল্পনা করতে Source 11সোর্স 11। Postman CLI-তে collection চালানোর command হলো postman collection run Source 12সোর্স 12।
How a tester uses it
- Check more than the status. Postman's own examples check the status code, the response time, and the fields of the JSON body Source 8সোর্স 8. A response time check reads
pm.expect(pm.response.responseTime).to.be.below(200)Source 8সোর্স 8. - Tell 401 from 403. A
401means the client must authenticate. A403means the server knows the client, but the client has no access rights Source 3সোর্স 3. Test both: a request with no token, and a request by a user who may not do the action. - Send a POST twice.
POSTis not guaranteed to be idempotent Source 4সোর্স 4. Send the samePOSTagain and check what the API does with the repeat. - One collection, several environments. An environment groups one set of values, for example one for the production server and another for testing Source 9সোর্স 9. Environment variables scope the work to one environment, such as local development, testing, or production, and one environment is active at a time Source 9সোর্স 9.
- Run it in CI. By default, Newman exits with code 0 when the run completes without errors. With
--bail, it stops and exits with code 1 when a test fails, so the CI tool can fail the build Source 11সোর্স 11. - Feed it data. The Collection Runner lets you choose the iteration data for a run Source 10সোর্স 10.
সহজ English
- Check more than the status. Postman's examples check the status code, the time the answer took, and the fields of the JSON body Source 8সোর্স 8.
- Know 401 from 403.
401: the client must prove who it is.403: the server knows the client, but it may not do this Source 3সোর্স 3. Test both: no token, and a user without the right. - Send a POST twice.
POSTmay not be idempotent Source 4সোর্স 4. Send the samePOSTagain and see what the API does. - One collection, several environments. An environment holds one set of values, like one for the live server and one for testing Source 9সোর্স 9. One environment is active at a time Source 9সোর্স 9.
- Run it in CI. By default, Newman ends with code 0 when the run has no errors. With
--bail, it stops and ends with code 1 when a test fails, so CI can fail the build Source 11সোর্স 11. - Feed it data. The Collection Runner lets you choose the iteration data for a run Source 10সোর্স 10.
বাংলা ব্যাখ্যা
- শুধু status নয়, আরও চেক করুন। Postman-এর নিজের উদাহরণগুলো status code, response time আর JSON body-র field চেক করে Source 8সোর্স 8। Response time-এর চেক দেখতে এমন:
pm.expect(pm.response.responseTime).to.be.below(200)Source 8সোর্স 8। - 401 আর 403 আলাদা করুন।
401মানে client-কে নিজের পরিচয় প্রমাণ করতে হবে।403মানে server client-কে চেনে, কিন্তু তার access-এর অধিকার নেই Source 3সোর্স 3। দুটোই টেস্ট করুন: token ছাড়া একটা request, আর এমন user-এর request, যার কাজটা করার অনুমতি নেই। - একই POST দুবার পাঠান।
POSTidempotent হবেই, এমন নিশ্চয়তা নেই Source 4সোর্স 4। একইPOSTআবার পাঠিয়ে দেখুন API সেটা নিয়ে কী করে। - এক collection, কয়েকটা environment। একটা environment এক সেট value রাখে, যেমন production server-এর জন্য এক সেট আর টেস্টের জন্য আরেক সেট Source 9সোর্স 9। Environment variable কাজটাকে একটা environment-এ সীমিত রাখে, যেমন local development, testing বা production, আর একবারে একটাই environment active থাকে Source 9সোর্স 9।
- CI-তে চালান। ডিফল্টভাবে run কোনো error ছাড়া শেষ হলে Newman code 0 দিয়ে বের হয়।
--bailদিলে কোনো টেস্ট fail করলেই থেমে code 1 দিয়ে বের হয়, যাতে CI tool build-কে fail করতে পারে Source 11সোর্স 11। - Data দিন। Collection Runner-এ একটা run-এর জন্য iteration data বেছে নেওয়া যায় Source 10সোর্স 10।
Common mistakes
- Expecting
200from every success. A create often answers201 Created, the typical response after aPOSTSource 3সোর্স 3. Check the exact code that the API promises. - Treating
401and403as one case. One means that the client is not authenticated; the other means that it has no access rights Source 3সোর্স 3. - Missing a
GETthat changes data. AGETshould only retrieve data Source 2সোর্স 2. If it changes data, report it. - Retrying a
POSTwithout a thought. A client can safely retry an idempotent request, butPOSTis not guaranteed to be idempotent Source 4সোর্স 4. - The same URL typed into every request. Store it in a variable, so that a change is made once Source 9সোর্স 9.
- A new pipeline built on Newman. Newman will not receive updates or fixes, and Postman asks you to plan to replace it with the Postman CLI in scripts and CI pipelines Source 11সোর্স 11.
সহজ English
- Expecting
200for every success. Creating something often answers201 Created, usually after aPOSTSource 3সোর্স 3. Check the exact code that the API promises. - Mixing up
401and403. One means "prove who you are", the other means "you may not" Source 3সোর্স 3. - Missing a
GETthat changes data. AGETshould only get data Source 2সোর্স 2. If it changes data, report it. - Sending a
POSTagain without thinking. A repeat is safe for an idempotent request, butPOSTmay not be idempotent Source 4সোর্স 4. - The same URL typed everywhere. Put it in a variable and change it once Source 9সোর্স 9.
- A new pipeline on Newman. Newman gets no more updates or fixes, and Postman says to replace it with the Postman CLI in scripts and CI pipelines Source 11সোর্স 11.
বাংলা ব্যাখ্যা
- প্রতিটা সফল উত্তরে
200আশা করা। কিছু তৈরি করলে উত্তর প্রায়ই201 Createdহয়, যা সাধারণতPOST-এর পরের response Source 3সোর্স 3। API ঠিক কোন code দেওয়ার কথা বলে, সেটাই চেক করুন। 401আর403-কে একই ধরা। একটার মানে client authenticated নয়; অন্যটার মানে তার access-এর অধিকার নেই Source 3সোর্স 3।- Data বদলে দেওয়া
GETচোখ এড়ানো।GETশুধু data আনবে Source 2সোর্স 2। Data বদলালে সেটা report করুন। - না ভেবে
POSTআবার পাঠানো। Idempotent request নিরাপদে আবার পাঠানো যায়, কিন্তুPOSTidempotent হবেই, এমন নিশ্চয়তা নেই Source 4সোর্স 4। - প্রতিটা request-এ একই URL হাতে লেখা। এটা একটা variable-এ রাখুন, যাতে বদলাতে হলে একবারেই হয় Source 9সোর্স 9।
- নতুন pipeline Newman দিয়ে বানানো। Newman আর কোনো update বা fix পাবে না, আর Postman বলে script আর CI pipeline-এ Newman-এর জায়গায় Postman CLI আনার পরিকল্পনা করতে Source 11সোর্স 11।
What a tester can check
Tutorial advice
This list is the tutorial's own advice, not a fact from a source.
- Status codes. Does each request check the exact status code, not only that it is a success?
- The body. Do the tests check the fields and the types of the JSON body, not only that it exists?
- Error cases. Is there a request for a missing field, a wrong type, no token, and a record of another user?
- Repeats. What does the API do when the same
POSTarrives twice? - Variables. Are the URLs and tokens in variables and environments, not typed into the requests?
- CI. Does the collection run in CI, and does one failed test fail the build?
সহজ English
Tutorial advice
This list is the tutorial's own advice, not a fact from a source.
- Status codes. Does each request check the exact status code?
- The body. Do the tests check the fields and types of the JSON, not only that it is there?
- Errors. Is there a request for a missing field, a wrong type, no token, and another user's record?
- Repeats. What happens when the same
POSTcomes twice? - Variables. Are URLs and tokens in variables, not typed into each request?
- CI. Does the collection run in CI, and does one failed test stop the build?
বাংলা ব্যাখ্যা
Tutorial advice
এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, কোনো source থেকে নেওয়া তথ্য নয়।
- Status code। প্রতিটা request কি ঠিক কোন status code আসবে তা চেক করে, শুধু সফল হলো কি না তা নয়?
- Body। টেস্টগুলো কি JSON body-র field আর type চেক করে, শুধু body আছে কি না তা নয়?
- Error case। Field না থাকা, ভুল type, token না থাকা আর অন্য user-এর record, এগুলোর জন্য request আছে কি?
- একই request দুবার। একই
POSTদুবার এলে API কী করে? - Variable। URL আর token কি variable আর environment-এ রাখা, নাকি request-এ হাতে লেখা?
- CI। Collection কি CI-তে চলে, আর একটা টেস্ট fail করলে কি build fail হয়?
Key words
| Term | Meaning |
|---|---|
| HTTP | A client-server protocol of the web; the client starts each request. |
| Method | What a request is for: GET, POST, PUT, PATCH, DELETE. |
| Status code | The result of a request, in one of five classes from 100 to 599. |
| Idempotent | One request has the same intended effect as several identical ones. |
| Query parameter | A key-value pair after ? in the URL. |
| Path parameter | A placeholder in the path, such as :id. |
| Post-response script | JavaScript that runs after the response arrives, with pm.test and pm.expect. |
| Variable | A stored value, such as {{base_url}}, used across requests. |
| Environment | One set of variable values, for example for a test server. |
| Collection Runner | Runs the requests of a collection in order and logs the test results. |
| Newman | Postman's command-line collection runner; it gets no more updates or fixes. |
| Postman CLI | The command-line tool that Postman asks you to move to: postman collection run. |