FMC - How to get multiple objects with the rest API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 02:12 PM
Hi experts, I am wondering if I can GET multiple network objects in one API call to the FMC. I found the following URL for querying one network object (from the postman collection)
{{protocol}}://{{hostname}}/api/fmc_config/v1/domain/{{domain_id}}/object/networks/{{network_id}}
I also have the same need for host objects and object groups and I hope the solution is the same for them.
Thanks!
Difan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 01:43 AM
Check if these procedures could work for you (not tested myself) , or else you may 'take hints' from these info's
- To get multiple objects with the REST API on Cisco FMC, you can use the GET
method and specify the objects you want to retrieve in the URL. For example, to get all of the objects in the "object_group" resource, you can use the following URL:
https://<FMC IP>/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/objectgroups
You can also filter the objects you retrieve by specifying query parameters in the URL. For example, to get all objects in the "object_group" resource that have the name "TestGroup", you can use the following URL:
https://<FMC IP>/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/objectgroups?name=TestGroup
Make sure to replace the <FMC IP>
placeholder with the actual IP address or hostname of your Cisco FMC device, and e276abec-e0f2-11e3-8169-6d9ed49b625f
with your domain UUID. You should also include a valid Authorization
header in your GET
request, with a value of "Bearer <access_token>", where <access_token>
is a valid token obtained by authenticating to the Cisco FMC.
M.
-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 09:53 AM
Thanks, Marce for your response. I apologize that I might not make my question clear... I know how to query for a specific object or all objects. However, is it possible to query for several objects with their object IDs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 11:07 PM
- Try to use the bulk export feature to export multiple objects of the same type (e.g. networks, host objects, object groups) in one API call. The URL for bulk export is as follows:
{{protocol}}://{{hostname}}/api/fmc_config/v1/domain/{{domain_id}}/object/{{object_type}}?expanded=true&limit={{limit}}&offset={{offset}}
where:
- {{protocol}} is the protocol used to access the FMC (e.g. https)
- {{hostname}} is the hostname or IP address of the FMC
- {{domain_id}} is the ID of the domain to which the objects belong
- {{object_type}} is the type of objects to be exported (e.g. networks, hostobjects, objectgroups)
- {{limit}} is the number of objects to be exported per API call
- {{offset}} is the starting position of the objects to be exported
You can also filter the export by adding additional query parameters to the url.
For example, you could use the following URL to export all network objects in the domain with ID "12345678-1234-1234-1234-123456789abc":
{{protocol}}://{{hostname}}/api/fmc_config/v1/domain/12345678-1234-1234-1234-123456789abc/object/networks?expanded=true
It's also possible to export multiple object types in one call. To do this, you would need to use the export endpoint with the object types separated by commas.
For example:
{{protocol}}://{{hostname}}/api/fmc_config/v1/domain/{{domain_id}}/object/networks,hostobjects,objectgroups
M.
-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 06:36 AM
I do not believe it is possible to GET multiple network objects based on their ID in one GET call, I don't think the API in FMC supports this...yet.
Please remember to select a correct answer and rate helpful posts
