Testing Ad Campaign API Response Structure and Properties Using Postman

Testing Ad Campaign API Response Structure and Properties Using Postman

This document explains how to test an advertising campaign API that gives info on interest groups, ad sizes, metadata, and bidding strategies. It breaks down the JSON response format and includes a thorough collection of automated tests in Postman to verify that the API provides correct and expected data. The tests check for response status, response time, data structure accuracy, and specific attributes tied to ads and their sizes, making sure the API is dependable for managing advertising campaigns.

PUT Request

https://at-us-east.amazon-adsystem.com/interestGroups/v2/join/

Response result

{
    "interestGroups": [
        {
            "adSizes": {
                "350x420": {
                    "height": 420,
                    "width": 350
                },
                "300x50": {
                    "height": 50,
                    "width": 300
                },
                "728x90": {
                    "height": 90,
                    "width": 728
                },
                "414x125": {
                    "height": 125,
                    "width": 414
                },
                "1920x1080": {
                    "height": 1080,
                    "width": 1920
                },
                "300x250": {
                    "height": 250,
                    "width": 300
                },
                "300x600": {
                    "height": 600,
                    "width": 300
                },
                "980x55": {
                    "height": 55,
                    "width": 980
                },
                "650x130": {
                    "height": 130,
                    "width": 650
                },
                "160x600": {
                    "height": 600,
                    "width": 160
                },
                "245x250": {
                    "height": 250,
                    "width": 245
                },
                "320x50": {
                    "height": 50,
                    "width": 320
                },
                "336x280": {
                    "height": 280,
                    "width": 336
                },
                "1920x1200": {
                    "height": 1200,
                    "width": 1920
                },
                "970x250": {
                    "height": 250,
                    "width": 970
                }
            },
            "ads": [
                {
                    "metadata": {
                        "adId": "589918608846340995",
                        "campaignId": "577581853979989519",
                        "creativeId": "587532414241231889",
                        "creativeSizes": [
                            "160x600",
                            "245x250",
                            "300x50",
                            "300x250",
                            "300x600",
                            "320x50",
                            "336x280",
                            "350x420",
                            "414x125",
                            "650x130",
                            "728x90",
                            "970x250",
                            "980x55",
                            "1920x1080",
                            "1920x1200"
                        ],
                        "flightId": "584131317959171128",
                        "geoMatch": false,
                        "googleBillingId": "7527776205",
                        "igAudienceCategory": "8",
                        "language": "en",
                        "realTimeMatch": true,
                        "sizeGroup": "g1"
                    },
                    "renderUrl": "https://at-us-east.amazon-adsystem.com/creative/https://aax-us-east-retail-direct.amazon.com/v1/ig/igcreative/http://prod-na-iad-shardf.molten.advertising.amazon.dev/creative?creativeId=587532414241231889&advertiserId=585957566706201540&adId=589918608846340995&campaignId=577581853979989519&flightId=584131317959171128&budgetId=589918608846340995&GoogleBillingId=7527776205&width=${AD_WIDTH}&height=${AD_HEIGHT}"
                }
            ],
            "biddingLogicUrl": "https://at-us-east.amazon-adsystem.com/biddingLogic/bidder_v2.js",
            "name": "293ceb3f-105f-4465-9abd-09ac915162c6",
            "owner": "https://at-us-east.amazon-adsystem.com/",
            "sizeGroups": {
                "g1": [
                    "160x600",
                    "245x250",
                    "300x50",
                    "300x250",
                    "300x600",
                    "320x50",
                    "336x280",
                    "350x420",
                    "414x125",
                    "650x130",
                    "728x90",
                    "970x250",
                    "980x55",
                    "1920x1080",
                    "1920x1200"
                ]
            },
            "trustedBiddingSignalsKeys": [
                "589918608846340995"
            ],
            "trustedBiddingSignalsUrl": "https://at-us-east.amazon-adsystem.com/biddingSignals/cs",
            "updateUrl": "https://at-us-east.amazon-adsystem.com/interestGroup/update?ig_name=293ceb3f-105f-4465-9abd-09ac915162c6&label=C-A1JSFF43SRWGQ6&m=1",
            "userBiddingSignals": {}
        }
    ]
}

Test Script

// Parse the JSON response
const jsonData = pm.response.json();

// Test: Response status is 200
pm.test("Response status is 200", function () {
pm.response.to.have.status(200);
});

// Test: Response time is less than 300ms
pm.test("Response time is acceptable", function () {
pm.expect(pm.response.responseTime).to.be.below(300);
});

// Test: Response has the correct structure
pm.test("Response structure is correct", function () {
pm.expect(jsonData).to.have.property('interestGroups').that.is.an('array').with.lengthOf.above(0);
pm.expect(jsonData.interestGroups[0]).to.include.keys('adSizes', 'ads', 'biddingLogicUrl', 'name', 'owner', 'sizeGroups', 'trustedBiddingSignalsKeys', 'trustedBiddingSignalsUrl', 'updateUrl', 'userBiddingSignals');
});

// Test: adSizes is an object with specific dimensions
pm.test("adSizes structure is valid", function () {
const adSizes = jsonData.interestGroups[0].adSizes;
pm.expect(adSizes).to.be.an('object');
// Validate specific ad sizes exist
pm.expect(adSizes).to.have.property('350x420');
pm.expect(adSizes['350x420']).to.include.keys('height', 'width');
pm.expect(adSizes['350x420'].height).to.be.a('number').and.to.be.above(0);
pm.expect(adSizes['350x420'].width).to.be.a('number').and.to.be.above(0);
});

// Test: ads is an array with expected properties
pm.test("ads structure is valid", function () {
const ads = jsonData.interestGroups[0].ads;
pm.expect(ads).to.be.an('array').with.lengthOf.above(0);
pm.expect(ads[0]).to.include.keys('metadata', 'renderUrl');
pm.expect(ads[0].metadata).to.include.keys('adId', 'campaignId', 'creativeId', 'creativeSizes', 'flightId', 'geoMatch', 'googleBillingId', 'igAudienceCategory', 'language', 'realTimeMatch', 'sizeGroup');
});

// Test: Check specific metadata values
pm.test("Metadata values are valid", function () {
const metadata = jsonData.interestGroups[0].ads[0].metadata;
pm.expect(metadata.adId).to.be.a('string');
pm.expect(metadata.campaignId).to.be.a('string');
pm.expect(metadata.creativeId).to.be.a('string');
pm.expect(metadata.creativeSizes).to.be.an('array').that.is.not.empty;
pm.expect(metadata.flightId).to.be.a('string');
});

// Test: Check URLs are valid
pm.test("URLs are valid", function () {
const biddingLogicUrl = jsonData.interestGroups[0].biddingLogicUrl;
const updateUrl = jsonData.interestGroups[0].updateUrl;
pm.expect(biddingLogicUrl).to.match(/^https?:\/\//);
pm.expect(updateUrl).to.match(/^https?:\/\//);
});

// Test: Check that trustedBiddingSignalsKeys is an array
pm.test("trustedBiddingSignalsKeys is an array", function () {
pm.expect(jsonData.interestGroups[0].trustedBiddingSignalsKeys).to.be.an('array');
});

// Test: Check sizeGroups contain expected size groups
pm.test("sizeGroups structure is valid", function () {
const sizeGroups = jsonData.interestGroups[0].sizeGroups;
pm.expect(sizeGroups).to.be.an('object');
pm.expect(sizeGroups).to.have.property('g1').that.is.an('array').with.lengthOf.above(0);
});

// Test: Check for presence of trustedBiddingSignalsUrl
pm.test("trustedBiddingSignalsUrl is present", function () {
pm.expect(jsonData.interestGroups[0]).to.have.property('trustedBiddingSignalsUrl').that.is.a('string');
});


Click here to see the Postman test results
Test DescriptionStatus
Response status is 200PASS
Response time is acceptablePASS
Response structure is correctPASS
adSizes structure is validPASS
ads structure is validPASS
Metadata values are validPASS
URLs are validPASS
trustedBiddingSignalsKeys is an arrayPASS
sizeGroups structure is validPASS
trustedBiddingSignalsUrl is presentPASS


Explanation of the Tests

1. Response Status

  • Purpose: Ensure the API responds with a status code of 200 (OK).

2. Response Time

  • Purpose: Verify that the response time is below an acceptable threshold (e.g., 200 ms).

3. Response Structure

  • Purpose: Confirm that the response contains the expected properties and that the interestGroups array is populated.

4. Ad Sizes Validation

  • Purpose: Check that the adSizes object contains specific dimensions and that the dimensions are valid numbers greater than 0.

5. Ads Validation

  • Purpose: Validate that the ads array contains properly structured objects with the necessary metadata.

6. Metadata Values

  • Purpose: Ensure that specific metadata fields are of the correct type and are populated correctly.

7. URL Validation

  • Purpose: Verify that the URLs in the response are valid and formatted correctly.

8. Array Validation

  • Purpose: Check that trustedBiddingSignalsKeys is an array.

9. Size Groups Validation

  • Purpose: Confirm that the sizeGroups object has the expected structure.

10. Trusted URL Check

  • Purpose: Ensure that trustedBiddingSignalsUrl is present in the response.

Scroll to Top