How do I format a a pm.response() test to include a an IP in the request?

I’m using postman to test a router for the state of a peer router. I expect it to return a status of “Established” from the peer router “peerState” key. Normally for these types of tests I used the pm.response module but in this case I have a value to get nested under an IP address in the response body like so:

    "jsonrpc": "2.0",
    "id": "show...",
    "result": [
            "routerId": "",
            "peers": {
                "": {
                    "msgSent": 21416,
                    "inMsgQueue": 0,
                    "prefixReceived": 0,
                    "upDownTime": 1543940743.718255,
                    "version": 4,
                    "msgReceived": 21420,
                    "prefixAccepted": 0,
                    "peerState": "Established",
                    "outMsgQueue": 0,
                    "underMaintenance": false,
                    "asn": 65001

I want to fetch the value in the peerState key but am having difficulty formatting the test:

pm.test("EVPN neighbor is established", function () {

Question: how do I format that dotted IP address in the pm.response test?

You could wrap it in []?



Totally worked; many thanks. Working version looks like this.

pm.test("EVPN neighbor: Established", function () {
1 Like