View action returns only one record

22 views
Skip to first unread message

Vaidotas Staugaitis

unread,
Mar 4, 2018, 2:46:15 PM3/4/18
to apidev
Hi,

My goal is to request information on multiple specific animals.  This example in API documentation led me to believe that View action is the right way to do this as it submits several locationID parameters.
However, JSON request below oreturn only one result.  Where am I going astray here?


Request Body:
{
   
"apikey" : "eQbHUNyF",
   
"objectType":"animals",
   
"objectAction":"publicView",
   
"values":[
       
{
           
"animalID":"589563"
       
},
       
{
           
"animalID":"589563"
       
}
   
],
   
"fields": ["animalID", "animalName"]
}
Response:
{
   
"status": "ok",
   
"messages": {
       
"generalMessages": [],
       
"recordMessages": []
   
},
   
"foundRows": 1,
   
"data": [
       
{
           
"animalID": "589563",
           
"animalName": "Charley the Husky"
       
}
   
]
}ode here...

Thanks.

Richard Saffell

unread,
Mar 4, 2018, 4:08:38 PM3/4/18
to apidev
Vaidotas,

The publicView action will only return one animal.

I think you want to use the publicSearch, and if you know the animalID of multiple animals you can use a filter on animalID with the operation equals, and provide an array of the animalIDs.  Let me know if you need example code.

Richard

Vaidotas Staugaitis

unread,
Mar 4, 2018, 4:31:17 PM3/4/18
to apidev
Great, thank you for the pointer.

Following code gave me what I am after:
{
   
"apikey" : "<get your own>",
   
"objectType":"animals",
   
"objectAction":"publicSearch",
   
"search":{
       
"resultStart":"0",
       
"resultLimit": "1000",
       
"filters":[
       
{
           
"fieldName":"animalID",
           
"operation":"equals",
           
"criteria":["589563", "2728485"]
       
}],
       
"fields": ["animalID", "animalLocationDistance"]

   
},
   
"fields": ["animalID", "animalName"]
}

Thank you.



Reply all
Reply to author
Forward
0 new messages