- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
REST API Call Response Filtering
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 08:26 AM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 08:00 AM
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"}