0

How do I make a GET request to this service below:

public class MyService {

  @GET
  @Path("/trendingcontent/home")
  Map<String, Object> getTrendingContentHome(@QueryParam("max") @DefaultValue("5") int max,
    @QueryParam("containerType") @DefaultValue("-1") int containerType,
    @QueryParam("containerID") @DefaultValue("-1") long containerID,
    @QueryParam("contentTypes") Set<Integer> objectTypes) {

    if (recommendationManager.isEnabled()) {
            EntityDescriptor descriptor = null;
            if (containerType > 0 && containerID > 0) {
                // only set the descriptor if the container is not root
                Community root = communityManager.getRootCommunity();
                if (containerType != root.getObjectType() || containerID != root.getID()) {
                    descriptor = new EntityDescriptor(containerType, containerID);
                }
            }

            RecommendationQuery query;
            if (objectTypes == null || objectTypes.isEmpty()) {
                objectTypes = recommendationQueryHelper.getContainableTypes();
            }

            if (descriptor == null) {
                query = recommendationQueryHelper.getSystemTrendingContent(objectTypes);
            }
            else {
                query = recommendationQueryHelper.getContainerTrendingContent(objectTypes, Sets.newHashSet(descriptor));
            }

            return getRecommendationResponse(query, max, home);
        }
        else {
            return getPopularContent(max, home);
        }

  }

}

I'm using this:

curl 'http://localhost:8080/__services/v2/rest/recommendation/trendingcontent/home/3/2020/1/1100' -H 'Host: localhost:8080' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'X-J-Token: 6430c792bc77967ce8c7' -H 'X-Requested-With: XMLHttpRequest'

My concern is how do I pass a Set as QueryParam. Is it possible to make a GET request with http data passed along?

Thanks for helping out.

drecute
  • 748
  • 4
  • 11
  • 29

1 Answers1

3

You pass query parameters as path parameters. The correct curl call is:

http://localhost:8080/__services/v2/rest/recommendation/trendingcontent/home?max=3&containerType=2020&containerID=1&contentTypes=1100

If you need more than one contentTypes use:

http://localhost:8080/__services/v2/rest/recommendation/trendingcontent/home?max=3&containerType=2020&containerID=1&contentTypes=1100&contentTypes=22340&contentTypes=43000
ragnor
  • 2,498
  • 1
  • 22
  • 25