CMDBuild Forum

Filter using REST API

I'm trying to get a filter to work on REST API requests - all of the options below fail to work or return everything.. Please help.

 

 

cmdbuild_url = "http://testCMDBuild:8080/cmdbuild/services/rest/v2/classes/AWSServer/cards"

#data = "{filter: '{\"attribute\":{\"simple\":{\"attribute\":\"CODE\",\"operator\":\"EQUALS\",\"value\":[\"FCP-AL-WEB-RN03\"]}}}'}"

#data = '{"CQL":"from AWSServer WHERE Description CONTAINS \'linux\'"}'

data = "{filter: '{\"cql\": \"from AWSServer where InstanceID EQUALS \'i-049347a98af506541\'\"}'}"

headers = {'Content-type': 'application/json', 'Accept': '*/*', 'CMDBuild-Authorization': sessionid }

r = requests.get(cmdbuild_url, data=json.dumps(data), headers=headers)

pprint (r.json())

 
Please, view this answare.
CMDBuild Team

Previously Grant wrote:

I'm trying to get a filter to work on REST API requests - all of the options below fail to work or return everything.. Please help.

cmdbuild_url = "http://testCMDBuild:8080/cmdbuild/services/rest/v2/classes/AWSServer/cards"

#data = "{filter: '{\"attribute\":{\"simple\":{\"attribute\":\"CODE\",\"operator\":\"EQUALS\",\"value\":[\"FCP-AL-WEB-RN03\"]}}}'}"

#data = '{"CQL":"from AWSServer WHERE Description CONTAINS \'linux\'"}'

data = "{filter: '{\"cql\": \"from AWSServer where InstanceID EQUALS \'i-049347a98af506541\'\"}'}"

headers = {'Content-type': 'application/json', 'Accept': '*/*', 'CMDBuild-Authorization': sessionid }

r = requests.get(cmdbuild_url, data=json.dumps(data), headers=headers)

pprint (r.json())