Forums

GET Groups by CategoryId

I'm trying to do a GET on Groups by only a specific category ID in javascript. I asked earlier about how to do this with the api key you said to do a post. For one this isn't RESTFUL at all. If all i'm doing is retrieving a resource I should never be doing a post. Anyways when I pull down the json I don't see any way to filter by which group Id I want. So my question is there a way to pass only the category id that I want to get the data for. The only other option I can for see is giving all the group names a common prefix or suffix to filter on. Thanks. 

Hi Jeremy.


The Elvanto API doesn't operate on RESTFUL principles, which is why everything works using POST statements. GET Statements can work for some endpoints, in particular the getAll endpoints, but won't allow you to send any arguments with the request. 


For this particular use case you want to use groups/getAll and send the category_id argument in your request, with the ID of the category you're wanting to filter by. Doing this will result in only groups in the supplied category being returned. For this you'd just need to send the following in the post statement.


{
	"category_id"= "some_category_id"
}

 

If you're wanting to grab multiple categories you can send an array.


 

{
	"category_id": ["category_1","category_2"]
}

 

Hope this helps,

Stewart


Login or Signup to post a comment