Trade Me-4-Retrieve your watchlist API testing | Postman API automation testing

API Function

Retrieves a list of items on the authenticated user’s watchlist.

API - Retrieve your watchlist script development steps

API Specification -> Business Presentation -> API Testing Script Debugging -> API Testing Script Enhancement -> API Testing Script Negative Cases Extension -> API Testing Script Publishment

API Specification

  • Key request fields

  • Key response fields - The Watchlist for the authenticated user.

    TotalCount Integer The total number of results in the collection. Can be larger than the number of returned results.
    Page Integer The index of the current page of results (starts at 1).
    PageSize Integer The number of results in the current page.
    List Collection of or null A list of the results in the current page.
    ListingId Long Integer The ID of the listing.
    BidCount Integer The number of bids on the item.

More API specification refers to Retrieve your watchlist .

  • Example request

GET https://api.tmsandbox.co.nz/v1/MyTradeMe/Watchlist/All.JSON

  • Example response

{
  "TotalCount": 1,
  "Page": 1,
  "PageSize": 1,
  "List": [
    {
      "ListingId": 2149294406,
      "Title": "11x Assorted T-Handle Hex Allen Keys",
      "Category": "5964-5999-6004-9825-",
      "StartPrice": 1.0000,
      "StartDate": "\/Date(1626749989730)\/",
      "EndDate": "\/Date(1626922789730)\/",
      "ListingLength": null,
      "AsAt": "\/Date(1626855531548)\/",
      "CategoryPath": "\/Building-renovation\/Tools\/Hand-tools\/Sets-kits",
      "PictureHref": "https:\/\/images.tmsandbox.co.nz\/photoserver\/thumb\/8152697.jpg",
      "PhotoId": 8152697,
      "RegionId": 16,
      "Region": "Canterbury",
      "Suburb": "Christchurch City",
      "Note": "",
      "NoteDate": "\/Date(0)\/",
      "CategoryName": "Sets & kits",
      "Attributes": [
        
      ],
      "Subtitle": "SKYLARC’S WINDFLOW TECHNOLOGY ONLINE AUCTION",
      "MinimumNextBidAmount": 1.0000,
      "IsOnWatchList": true,
      "PriceDisplay": "$1.00",
      "AdditionalData": {
        "BulletPoints": [
          
        ],
        "Tags": [
          
        ]
      },
      "IsDealer": false,
      "IsLeading": false,
      "IsOutbid": false,
      "IsInCart": false,
      "MemberBidShippingOption": 0
    }
  ],
  "FoundCategories": [
    {
      "Count": 1,
      "Category": "5964-",
      "Name": "Building & renovation",
      "CategoryId": 5964
    }
  ]
}

Business Presentation

  • Front-end page - Go to watchlist page

Login > Watchlist > View Watchlist

  • Front-end page - Watchlist page

  • Business scope selection

Query items in the watch list.

  • Business verification points

Checking there are or aren’t items in the watch list.

API Testing Script Debugging

  • Choose the OAuth 1.0 in the Authorization label of Postman to authorize the request.

The OAuth 1.0 is for the transaction that needs to be authorized before sending. Template likes the below:

Base on the API specification, parameter - All means return all items from the watchlist.

So the request should be GET https://api.tmsandbox.co.nz/v1/MyTradeMe/Watchlist/All.JSON

  • API connectivity

The connectivity test passes and gets a response example that the watch list has no items.

{
    "TotalCount": 0,
    "Page": 1,
    "PageSize": 0,
    "List": [],
    "FoundCategories": []
}

The connectivity test passes and gets a response example that the watch list has items.

{
    "TotalCount": 1,
    "Page": 1,
    "PageSize": 1,
    "List": [
        {
            "ListingId": 2149294806,
            "Title": "Digitus DK-330301-00",
            "Category": "0002-4250-4256-",
            "StartPrice": 0,
            "BuyNowPrice": 37.31,
            "StartDate": "/Date(1626835762520)/",
            "EndDate": "/Date(1627440562520)/",
            "ListingLength": null,
            "AsAt": "/Date(1627290227336)/",
            "CategoryPath": "/Computers/Cables-adaptors/Other",
            "PictureHref": "https://images.tmsandbox.co.nz/photoserver/thumb/8240722.jpg",
            "PhotoId": 8240722,
            "IsNew": true,
            "RegionId": 2,
            "Region": "Auckland",
            "Suburb": "Waitakere",
            "HasBuyNow": true,
            "Note": "",
            "NoteDate": "/Date(0)/",
            "CategoryName": "Other",
            "ReserveState": 3,
            "Attributes": [],
            "IsBuyNowOnly": true,
            "IsOnWatchList": true,
            "PriceDisplay": "$37.31 per item",
            "AdditionalData": {
                "BulletPoints": [],
                "Tags": []
            },
            "IsDealer": false,
            "IsLeading": false,
            "IsOutbid": false,
            "IsInCart": false,
            "MemberBidShippingOption": 0
        }
    ],
    "FoundCategories": [
        {
            "Count": 1,
            "Category": "0002-",
            "Name": "Computers",
            "CategoryId": 2
        }
    ]
}
  • API checkpoint

We can know the TotalCount >= 0 from the connectivity testing response.

Then we get the checking code snippet below base on the example feature.

pm.test("Checking if there are any items in the watch list", function () {

    console.log("Post-Transaction: CheckingtheCountsofWatchList Start");

    var jsonData = pm.response.json();

    var TotalCount = jsonData.TotalCount;  

    if (TotalCount >= 0){

        console.log("Found " + TotalCount +" item on the watch list");

        console.log("Post-Transaction: CheckingtheCountsofWatchList Pass");

    }

    else{

        console.log("Post-Transaction: CheckingtheCountsofWatchList Failed");

    }
    
});

Run script to verify the checkpoint works from console log.

API Testing Script Enhancement

Enhance the script, such as to add the transactional function, exceptional verification, parameterization, etc.

Run the final script and to verify from front-end page or console log.

API Testing Script Publishment

Move script from debug folder to public folder when we finished API positive and negative cases.

Then wait to be published to the GitHub specific repo combining with other scripts using the CICD tool.

Copyright

This work is licensed under CC BY-NC-ND 4.0 .