15 Days of Postman — for Testers — Day 01: API Client

Yasemin Gürbüz
5 min readJul 25, 2024

--

Merhaba! Postman ile 15 günlük bir yolculuğa çıkıyoruz ve bu serinin ilk gününde sizlere, ilk gün görevimizi nasıl tamamladığımıza dair adım adım rehber sunacağım. Ödevi yaparken aldığım hataların çözümünü ileteceğim.

Postman 15 günlük challenge’ına buradan ulaşabilirsiniz. Her bir day içinde ödevin dokümanları bulunmaktadır. Her bir adımı doğru yaptığınız takdirde testleriniz başarılı olacaktır.

Amaç: Bugün Postman’de farklı bir projeden collection forklama, request oluşturmayı öğreniceğiz.

1. Projeyi Kendi Workspace’imize Alma

  • Create a public Postman workspace: To create a public workspace
  1. Postman’e login olun. (Eğer üyeliğiniz yoksa yeni bir üyelik oluşturun.)
  2. Workspaces -> Create Workspace
  3. Boş workspace seçip ->Next
  4. Workspace isim verin -> Create tıklayın.
Workspace oluşturma

Workspace oluşturma

  • Fork the Parent Collection: To fork a collection
  1. 15 Days of Postman — for Testers sayfasına gidin.
  2. Day 01 gününün sağında bulunan üç noktaya tıklayın.
  3. Create a fork tıklayın.
Create a fork

4. Açılan ekranda fork alanında istediğiniz ismi verebilirsiniz. Workspace alanında ise oluşturduğunuz workspace seçmelisiniz. Ardından “Fork Collection” tıklayın.

Fork oluşturma 2

5. Kendi workspace’inize yönlenecek ve Day 01'in oluştuğunu göreceksiniz.

6. Her günün ödevinin dokümantasyonu “View compelete documentation” linkinden takip etmelisiniz. Testlerin başarılı olması için her bir adımı doğru yapmalısınız.

Artık hazırız, ödevimize başlayabiliriz.

Day 01 — Api Client

Adım 1: Import the request : Import the following data into Postman as Raw text. Then save the request to this collection under the API client folder. Name the request echo

  1. Workspace adının yanındaki “Import” butonuna tıklayın.
  2. Aşağıdaki kodu yapıştırın.
curl --location --request POST 'https://postman-echo.com/post' \
--header 'Content-Type: application/json' \
--data-raw '{
"payload": "hello world!"
}'

3. Oluşturulan request’te “Save” butonuna tıklayın.

4. Request Name alanına echo yazın.

5. Klasörde Day 01 — Api Client ->Api client seçin.

6. Save butonuna tıklayın.

Request Kaydetme

API client klasöründe echo adında request oluştuğunu göreceksiniz.

Adım 2: Review the request: Notice the different parts of this API request.

Request’imizi oluşturmuş olduk.

  1. HTTP request method — POST
  2. Request URL — https://postman-echo.com/post
  3. Request body — Body tabı altında JSON seçili.
  4. Bu üç adımı kontrol etmelisiniz.
  5. Eğer doğru ise “Send” butouna tıklayarak çalıştırabiliriz.
Request

Adım : 3 Send the request: Send the request, and look at the response on the bottom.

  • HTTP status code
  • Response time
  • Response size
  • Response body

Request’inizi gönderdikten sonra, API’den gelen response’u göreceksiniz. Bu response, API’nin döndürdüğü veriyi ve response status kodunu içerecek. 200 OK gibi bir status kodu, request’in başarılı olduğunu gösterir.

Adım :4 Update the request: Update the value of the payload property in the request body to something else besides hello world!.

Body alanında bulunan “Hello world” yazısını değiştirin. Tekrar “Send” butonuna tıklayın.

Payload yazısının değiştirme

NOT: Her adımda “Save” botununa tıklamayı unutmayınız!

Adım 5: Submit your colleciton

  1. Get the collection ID: Select the collection in the sidebar. Then in the context bar to the right, select the Info icon and copy the collection ID. Make sure you're getting the ID for the collection, and not this request.

Collection ID Alınması

Koleksiyona tıklayın. En sağda bulunan (i) ikonuna tıklayın. Collection Detailes bulunan ID bilgisini kopyalayın.

Koleksiyon id bilgisi

2. Update the request URL: Update the collection_uid in the request URL with the collection ID from the previous step, by pasting it into the request URL field.

Submit collection requestinde, linkteki kırmızı yazı ile {{collection_uid}} yazılan yer silinip kopyaladığımız id yapıştırılacak.

Collection id

3. Get your Postman API Key: Create a new Postman API Key and then open Postman Vault (Accessed via the bottom right menu bar). Create a new Postman Vault variable called postman_api_key and add your Postman API Key as the Value. Once the changes are saved, Postman will use the Postman Vault variable to authorize your request as shown under the Headers tab of the request.

Postman api key oluşturmalısınız.

4. Ödevdeki linke tıklayın -> Generate Api Key butonuna tıklayın. Oluşturulan api key’i kopyalayın.

5. Requestteki Header tabını tıklayın.

6. Key alanına x-api-key value değerine {{postman_api_key}} yazın.

7. {{postman_api_key}} üzerine geldiğinizde kutucuk çıkacak. “Add a new variable tıklayın ve oluşturduğunuz apikeyi yapıştırın.

postman api key kaydetme

8. Validate your solution: Hit Send and look under the Test Results tab of the server response at the bottom to review your test results.

Sırasıyla Save -> Send butonlarına tıklayın.

9. Testin başarılı olduğu ve (4/4) başarılı olduğu görülür.

Submit Collectio Test Sonucu

Adım 6 : Submit workspace

Get the workspace ID: Select your workspace name in the sidebar. Then select the Info icon on the far right,, and copy the workspace ID.

  1. Workspace adına tıklanır.
  2. Sağda bulunan üç noktaya tıklanır.
  3. Workspace info yazısına tıklanır.
  4. Çıkan workspace id kopalanır.
Workspace info

Update the request URL: Update the workspace_id in the request URL with the ID from the previous step, using any method you prefer.

  1. Submit workspace request, linkte bulunan {{workspace_id}} yerine yapıştırılır.

2. Header tabında Adım 5: 6. daki gibi postman_api_key değeri girilir.

Validate your solution: Hit Send and look under the Test Results tab of the server response at the bottom to review your test results.

  1. Sırasıyla Save -> Send butonlarına tıklayın.

2. Testin başarılı olduğu görülür.

Submit workspace test sonucu

Umarım bu makale ilk günü çözmenize yardımcı olmuştur. Okuduğunuz için teşekkür ederim.

2. günün ödevinde görüşmek üzere :)

Yasemin’s Workspace

--

--