Try adding fields=embed(addresses)
And then if you don’t need the links (which can be calculated from the other data), you can shorten the output by using a header of "accept": "application/json" instead of "accept": "application/hal+json"
https://{{bamip}}/api/v2/zones/{{zoneid}}/resourceRecords?fields=embed(addresses),type,name,absoluteName,addresses.type,addreses.name,addresses.address
Example Response
{
"count": 7,
"data":
{
"type": "GenericRecord",
"name": "helloworld",
"absoluteName": "helloworld.bluecatlabs.co.uk"
},
{
"type": "HostRecord",
"name": "bdds1",
"absoluteName": "bdds1.bluecatlabs.co.uk",
"addresses":
{
"type": "IPv4Address",
"address": "192.168.1.4"
},
{
"type": "IPv6Address",
"address": "2a00:23c6:a8b5:e101:e80d:e717:3364:4"
}
]
},
{
"type": "HostRecord",
"name": "bam2",
"absoluteName": "bam2.bluecatlabs.co.uk",
"addresses":
{
"type": "IPv4Address",
"address": "192.168.1.3"
},
{
"type": "IPv6Address",
"address": "2a00:23c6:a8b5:e101:e80d:e717:3364:3"
}
]
},
{
"type": "HostRecord",
"name": "bdds2",
"absoluteName": "bdds2.bluecatlabs.co.uk",
"addresses":
{
"type": "IPv4Address",
"address": "192.168.1.5"
},
{
"type": "IPv6Address",
"address": "2a00:23c6:a8b5:e101:e80d:e717:3364:5"
}
]
},
{
"type": "HostRecord",
"name": "bam1",
"absoluteName": "bam1.bluecatlabs.co.uk",
"addresses":
{
"type": "IPv4Address",
"address": "192.168.1.2"
},
{
"type": "IPv6Address",
"address": "2a00:23c6:a8b5:e101:e80d:e717:3364:2"
}
]
},
{
"type": "AliasRecord",
"name": "DNS",
"absoluteName": "DNS.bluecatlabs.co.uk"
},
{
"type": "HostRecord",
"name": "newapp",
"absoluteName": "newapp.bluecatlabs.co.uk",
"addresses":
{
"type": "IPv4Address",
"address": "192.168.1.89"
}
]
}
]
}
Thanks to both of you for your answers. I didn’t know about embed().
However I have a problem: if I query
“/api/v2/zones/<id>/resourceRecords?fields=embed(addresses)”
it works but I receive all fields, which is huge.
As soon, as I add other fields, the other fields are returned, but not the embed(addresses).
I did a copy/paste of your suggestion with
https://{{bamip}}/api/v2/zones/{{zoneid}}/resourceRecords?fields=embed(addresses),type,name,absoluteName,addresses.type,addreses.name,addresses.address
and my BAM (9.6.1 latest patch) replies differently:
I get type, name, absoluteName, but that’s all!
Strange…
Should I open a call?
The above output from me is from a 25.1 Beta3 system, however the API should be operating in a very similar fashion under 9.6.1
The “addresses.type,addresses.name,addresses.address” fields do not work for me in 9.5.3, 9.6.1, or 25.1 beta.
What works for me is:
fields=embed(addresses),type,name,absoluteName,_embedded.addresses.type,_embedded.addresses.name,_embedded.addresses.address
Yes! This works for me. Makes sense indeed.
Thanks for you help to all of you.
Thanks for the great question @thierry.van-mol