Postman testing of Banner Advertisement Response Data in POST Request

Postman testing of Banner Advertisement Response Data in POST Request

POST Request

Click to see the whole request
curl 'https://www.kupujemprodajem.com/api/web/v1/banners' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9,hr;q=0.8' \
  -H 'content-type: application/json' \
  -H 'cookie: _ga=GA1.1.1569828476.1730632173; _fbp=fb.1.1730632173381.546315793731152677; welcome_modal=1; _cc_id=6555db74fd9dab5c3f9f81aef64eba68; panoramaId_expiry=1731236974951; panoramaId=7ebb635888ca61fe66a1270ca1f016d5393898284d40d90e10eea095a3118024; panoramaIdType=panoIndiv; cto_bundle=wMiRuF85d09GVExHUjBBSEh1WXJOWmF1NnhpSUp5U0ZQVERmeDN1ZmpGZ0dXYjhyTVJYNFJXNjlxMGZNUW1TUHNtUjNzejVoV2xhQlo0NFRybnF0RE5YdGtCbmc2c3Y4MFltUnl1dWdoOWNOQWxYJTJGQmN6RWRseldHbk43bVoxRkJuUFc5RDU0UVphSVJkSGhldW5OQmFVVk5wQSUyRiUyQmdCdyUyQnpFamVOVUpQV1FQR2FITSUzRA; __gads=ID=c35205c10643307f:T=1730632174:RT=1730632174:S=ALNI_Mb-X1tuA_l3MYF5Fx7LrzkVeqQBVw; __gpi=UID=00000f50d5d7a84b:T=1730632174:RT=1730632174:S=ALNI_MZYk52CMgNzLKaPBn0QkK4OHgxrtg; __eoi=ID=6112bd64288697f5:T=1730632174:RT=1730632174:S=AA-AfjY_Qtj_0BQlczF9apqT_SbL; KUPUJEMPRODAJEM=nqqstisli733fg2jo3j41vg7s2; machine_id=899d93aae84f3b1701d028a180fc7903; FCNEC=%5B%5B%22AKsRol8CbLS7MgxedDjusU9KNJbqR2OV2JOocuvGqizc22tWkQ4LpuD87KdAtkNjUemLXPF0GxDjoGEeXjfLUiE2UU1SmDh2zIseQjo4fQgovtrAZiraFJFU2TCdFvHB2ie16lTKrwDZ1ww7VCna0pFUF2U_tAc7XQ%3D%3D%22%5D%5D; screenWidth=791; _ga_MD1JVXY53Y=GS1.1.1730632173.1.1.1730632232.1.0.1478389094' \
  -H 'origin: https://www.kupujemprodajem.com' \
  -H 'priority: u=1, i' \
  -H 'referer: https://www.kupujemprodajem.com/automobili/renault/renault-kangoo/oglas/173667159' \
  -H 'sec-ch-ua: "Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36' \
  -H 'x-kp-channel: desktop_react' \
  -H 'x-kp-dark: false' \
  -H 'x-kp-machine-id: 899d93aae84f3b1701d028a180fc7903' \
  -H 'x-kp-session: nqqstisli733fg2jo3j41vg7s2' \
  -H 'x-kp-signature: c514b434f0eeccb2b00b5667a220798b9de486fb' \
  -H 'x-kp-theme: system' \
  --data-raw '{"excludeBannerTypes":[],"bannerPositionId":[1,301,302,303,304,305,308],"pageType":"ads","firstParam":"automobili","group":"renault","ad":"renault-kangoo","adId":"173667159","groupId":2079,"categoryId":2013}'

Response

This response and test check the data received from a POST request meant for showing banner ads on a website. The response features a well-organized JSON object that shows whether the request was successful, lists any errors if there are any, and includes a detailed results section with several banners, each marked by a unique bannerPositionId. Each banner has details like bannerId, bannerType, and bannerData, along with targeting parameters (like category, channel, and price range) and a verification string (info2).

Click here to see the complete response
{
    "success": true,
    "errors": [],
    "results": {
        "301": {
            "bannerPositionId": 301,
            "bannerId": 94495,
            "bannerType": "dfp",
            "bannerData": {
                "dfpNetworkId": "80064797",
                "adUnit": "1",
                "targetingArguments": {
                    "c": "Automobili",
                    "g": "Renault",
                    "t": "ads",
                    "rnd": 1,
                    "p": "none",
                    "ud": false,
                    "ad_price": "lux",
                    "channel": "desktop_react",
                    "registered_users": "other",
                    "house": 1
                }
            },
            "info2": "wGC9WRtSheXwPRjL5eS/ppdsEYoM6XZleX0ZTi8H4PN5r8mLa6XZ5cJDn9l9y8RBM6zudhd7jgkRDb4FhVtvV9lRBylSzbF9j8D0HltkSxo="
        },
        "302": {
            "bannerPositionId": 302,
            "bannerId": 94790,
            "bannerType": "dfp",
            "bannerData": {
                "dfpNetworkId": "80064797",
                "adUnit": "2",
                "targetingArguments": {
                    "c": "Automobili",
                    "g": "Renault",
                    "t": "ads",
                    "rnd": 6,
                    "p": "none",
                    "ud": false,
                    "ad_price": "lux",
                    "channel": "desktop_react",
                    "registered_users": "other",
                    "house": 1
                }
            },
            "info2": "wGC9WRtSheXwPRjL5eS/ppdsEYoM6XZleX0ZTi8H4PN5r8mLa6XZ5cJDn9l9y8RBM6zudhd7jgkRDb4FhVtvV9lRBylSzbF9j8D0HltkSxo="
        },
        "304": {
            "bannerPositionId": 304,
            "bannerId": 94791,
            "bannerType": "dfp",
            "bannerData": {
                "dfpNetworkId": "80064797",
                "adUnit": "54",
                "targetingArguments": {
                    "c": "Automobili",
                    "g": "Renault",
                    "t": "ads",
                    "rnd": 7,
                    "p": "none",
                    "ud": false,
                    "ad_price": "lux",
                    "channel": "desktop_react",
                    "registered_users": "other",
                    "house": 1
                }
            },
            "info2": "wGC9WRtSheXwPRjL5eS/ppdsEYoM6XZleX0ZTi8H4PN5r8mLa6XZ5cJDn9l9y8RBM6zudhd7jgkRDb4FhVtvV9lRBylSzbF9j8D0HltkSxo="
        },
        "308": {
            "bannerPositionId": 308,
            "bannerId": 94974,
            "bannerType": "dfp",
            "bannerData": {
                "dfpNetworkId": "80064797",
                "adUnit": "308",
                "targetingArguments": {
                    "c": "Automobili",
                    "g": "Renault",
                    "t": "ads",
                    "rnd": 1,
                    "p": "none",
                    "ud": false,
                    "ad_price": "lux",
                    "channel": "desktop_react",
                    "registered_users": "other",
                    "house": 2
                }
            },
            "info2": "wGC9WRtSheXwPRjL5eS/ppdsEYoM6XZleX0ZTi8H4PN5r8mLa6XZ5cJDn9l9y8RBM6zudhd7jgkRDb4FhVtvV9lRBylSzbF9j8D0HltkSxo="
        }
    }
}

Test Script

The Postman test ensures that the response matches the expected formats and values. It confirms that the response shows success and no errors and that each banner has the right IDs, types, and structure. It also checks that the bannerData is intact and that info2 is valid. This process ensures that the banner data is properly configured and ready to be displayed to users.

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

// Test the overall response structure
pm.test("Response has success as true", function() {
    pm.expect(response).to.have.property("success", true);
});

pm.test("Response has an empty errors array", function() {
    pm.expect(response).to.have.property("errors").that.is.an("array").that.is.empty;
});

pm.test("Response contains results object", function() {
    pm.expect(response).to.have.property("results").that.is.an("object");
});

// Define expected structure for each banner position
const expectedStructure = {
    bannerPositionId: "number",
    bannerId: "number",
    bannerType: "dfp",
    bannerData: {
        dfpNetworkId: "80064797",
        adUnit: "string",
        targetingArguments: {
            c: "Automobili",
            g: "Renault",
            t: "ads",
            rnd: "number",
            p: "none",
            ud: false,
            ad_price: "lux",
            channel: "desktop_react",
            registered_users: "other",
            house: "number"
        }
    },
    info2: "string"
};

// Iterate over each result in the results object
Object.keys(response.results).forEach(bannerPosition => {
    const banner = response.results[bannerPosition];

    pm.test(`Banner ${bannerPosition} has correct bannerPositionId and bannerId`, function() {
        pm.expect(banner).to.have.property("bannerPositionId", parseInt(bannerPosition));
        pm.expect(banner).to.have.property("bannerId").that.is.a("number");
    });

    pm.test(`Banner ${bannerPosition} has correct bannerType`, function() {
        pm.expect(banner).to.have.property("bannerType", expectedStructure.bannerType);
    });

    pm.test(`Banner ${bannerPosition} contains valid bannerData`, function() {
        pm.expect(banner).to.have.property("bannerData").that.is.an("object");
        pm.expect(banner.bannerData).to.have.property("dfpNetworkId", expectedStructure.bannerData.dfpNetworkId);
        pm.expect(banner.bannerData).to.have.property("adUnit").that.is.a("string");
        
        pm.expect(banner.bannerData).to.have.property("targetingArguments").that.is.an("object");
        const args = banner.bannerData.targetingArguments;

        // Validate targetingArguments fields
        pm.expect(args).to.have.property("c", expectedStructure.bannerData.targetingArguments.c);
        pm.expect(args).to.have.property("g", expectedStructure.bannerData.targetingArguments.g);
        pm.expect(args).to.have.property("t", expectedStructure.bannerData.targetingArguments.t);
        pm.expect(args).to.have.property("rnd").that.is.a("number");
        pm.expect(args).to.have.property("p", expectedStructure.bannerData.targetingArguments.p);
        pm.expect(args).to.have.property("ud", expectedStructure.bannerData.targetingArguments.ud);
        pm.expect(args).to.have.property("ad_price", expectedStructure.bannerData.targetingArguments.ad_price);
        pm.expect(args).to.have.property("channel", expectedStructure.bannerData.targetingArguments.channel);
        pm.expect(args).to.have.property("registered_users", expectedStructure.bannerData.targetingArguments.registered_users);
        pm.expect(args).to.have.property("house").that.is.a("number");
    });

    pm.test(`Banner ${bannerPosition} has info2 as a string`, function() {
        pm.expect(banner).to.have.property("info2").that.is.a("string");
    });
});
Click to see the test results
StatusDescription
PASSResponse has success as true
PASSResponse has an empty errors array
PASSResponse contains results object
PASSBanner 301 has correct bannerPositionId and bannerId
PASSBanner 301 has correct bannerType
PASSBanner 301 contains valid bannerData
PASSBanner 301 has info2 as a string
PASSBanner 302 has correct bannerPositionId and bannerId
PASSBanner 302 has correct bannerType
PASSBanner 302 contains valid bannerData
PASSBanner 302 has info2 as a string
PASSBanner 304 has correct bannerPositionId and bannerId
PASSBanner 304 has correct bannerType
PASSBanner 304 contains valid bannerData
PASSBanner 304 has info2 as a string
PASSBanner 308 has correct bannerPositionId and bannerId
PASSBanner 308 has correct bannerType
PASSBanner 308 contains valid bannerData
PASSBanner 308 has info2 as a string

Scroll to Top