Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
hmx8
New Contributor II

FCT EMS Cloud API: using filters in Python's request.get

Hello,

 

I'm trying to use the filters object by group name using request.get (Python) via the FCT EMS Cloud API (see FortiClient EMS - FortiAPI - FNDN (fortinet.net)). So far I can't get it to work properly: if I run the following code (below is just the relevant get request of the code), the request gets authenticated and runs through. But the returned result still contain the index of all endpoint entries. Means, the filter setting seems note to be recognised for whatever reason. Please not that I've tried both 'group' as well as 'group_name' as key. Makes no difference.

Any example or idea from anybody?

Thanks a lot!

 

---- 8<-- code snipped-----

import requests
import json
<...>
filters = {'group':'VPN-Hub-HH-7-2-1'}
print (r.url)
r_dict = r.json()
print(json.dumps(r_dict, indent=4))

<...>

---- \-- code snipped-----

 

BTW, if I use a json object for the filter definition to pass to the params of the request method I get the a value error of "ValueError: not enough values to unpack (expected 2, got 1)":

 

params = [ { 'filters': {'group':'VPN-Hub-HH-7-2-1'} } ]
print (r.url)
r_dict = r.json()
print(json.dumps(r_dict, indent=4))
 
---- UPDATE :) -------
Maybe one or the other is interested: I got it to work by using both "group_id" and "group_name" in the "filters" object. See below:
---- 8<--- code snip ------
<...>
filters = {'group_id':'7','group_name':'VPN-Hub-HH-7-2-1'}
<...>
----- \ code snip --------
1 Solution
hmx8
New Contributor II

Hi Anthony,

 

thanks a lot. By now I managed to get it to work. Maybe not in the most elegant way but it works. Via EMS Cloud API I can now:

- get all endpoints tagged with a certain zero trust tag

- compare them with the endpoints in a given workgroup

- move endpoints who are not in that workgroup into it

 

It required a little effort to find out about the EMS Cloud API and to get a grip of the data structures been used by EMS (just say dict of dict with nested lists :) ). Postman and HTTP Watch help a lot here. But it would be great if FortiNet could invest some time to update the API docu in the EMS Cloud admin guide and on DevNet. ;)

 

Regards,

Holger

 

 

View solution in original post

3 REPLIES 3
Anthony_E
Community Manager
Community Manager

Hello hmx8,


Thank you for using the Community Forum. I will seek to get you an answer or help. We will reply to this thread with an update as soon as possible.


Thanks,

Anthony-Fortinet Community Team.
hmx8
New Contributor II

Hi Anthony,

 

thanks a lot. By now I managed to get it to work. Maybe not in the most elegant way but it works. Via EMS Cloud API I can now:

- get all endpoints tagged with a certain zero trust tag

- compare them with the endpoints in a given workgroup

- move endpoints who are not in that workgroup into it

 

It required a little effort to find out about the EMS Cloud API and to get a grip of the data structures been used by EMS (just say dict of dict with nested lists :) ). Postman and HTTP Watch help a lot here. But it would be great if FortiNet could invest some time to update the API docu in the EMS Cloud admin guide and on DevNet. ;)

 

Regards,

Holger

 

 

Anthony_E
Community Manager
Community Manager

Hello Holger,

 

Thank you for this precision. I will put your post as a solution.

 

Regards,

Anthony-Fortinet Community Team.
Labels
Top Kudoed Authors