Selecting fields in Ontology Search Objects REST API response

Hello, I use the REST API search endpoint to retrieve some Ontology objects. I want to retrieve only specific fields from the response, but the body I send doesn’t seem to be valid. What am I missing ?

body:

{
	"where": {
		"type": "eq", 
		"field": "mySearchedField", 
		"value": "abcdef"
	},
	"select": "id"
}

response:

{
	"errorCode": "INVALID_ARGUMENT",
	"errorName": "Conjure:UnprocessableEntity",
	"errorInstanceId": "d48ed596-6da8-4048-b2f7-edaf07d3e29a",
	"parameters": {}
}

If I remove the select key, the search works as expected.

Thanks :slight_smile:

The documentation says:

select list<PropertyApiName>

So I guess you have to write select: ["id"] instead?

I tried, same result :frowning:

Ok, strange as that works for me, e.g. if I try the following search request dict, passed to a requests.post() call in the json argument:

{
   "where": {
		"type": "eq", 
		"field": "id", 
		"value": "abcdef"
	},
	"select": ["id"]
}

I get a response printed with response.json() as:

{
  'data': [
    {'__apiName': 'ObjectTypeId', 
     '__rid': 'ri.phonograph2-objects.main.object.<snip>', 
     'id': 'abcdef', 
     '__primaryKey': 'abcdef'}
  ], 
  'totalCount': '1'
}

If I don’t put the ‘select’ into a list, I get the same INVALID_ARGUMENT response you have above.

You’re right, this works… I was sure I had tried it before with no success, my bad. Thanks for your help :slight_smile:

1 Like