Reply

REST API Call Response Filtering

New Member
Posts: 1
1396     0

Hello,

 

I am building an integration with our on premise DDI and am interfacing it with the REST API. I am trying to pull back A records and list them based on different extensible attributes. One thing I notice though is that on all responses, the _ref parameter/key is alwasy returned, even when specifying _return_fields. Is there a way to remove that parameter in the response body to make for easier filtering/querying?

Re: REST API Call Response Filtering

New Member
Posts: 1
1396     0

To the best of my knowledge, I don't think there's a way to "remove that parameter in the response body" (from the perspective of preventing IB from returning the_ref). The "_ref" is a unique ID for every item in InfoBlox, which means if you want to edit any items (literally anything: networks, containers, hosts, etc.), then you will need the _ref (you can still create items without it, and certainly you can get data back, like you said).

 

That being said, for the purpose of filtering data, you can use something like the following Python (you'd just be using the list comprehensions to sort your desired data).

 

import requests

response = requests.get(your_infoblox_url, headers=your_headers, params=your_params)
data = response.json()

# If the response is a list of dictionaries:
cleaned_data = [{k: v for k, v in item.items() if k != "_ref"} for item in data]

# If the response is a single dictionary:
cleaned_data = {k: v for k, v in data.items() if k != "_ref"}
Showing results for 
Search instead for 
Did you mean: 

Recommended for You