Question

Is there anyway in WSO2 Data Services Server to register a service that exposes a resource with two GET methods with the same base URL, one to get all resources and other one to get only a specific resource. For example:

  • [HTTP GET] academics/courses: Returns all courses
  • [HTTP GET] academics/courses/9789: Returns the course with code 9789

For that I tried with the following configuration:

<data ...>
    ...

    <resource method="GET" path="academics/courses"> 
      <call-query href="getAllCoursesQuery"/> 
    </resource>

    <resource method="GET" path="academics/courses/{code}"> 
      <call-query href="getCourseByCodeQuery"> 
         <with-param name="courseCode" query-param="code"/> 
      </call-query> 
    </resource>

    ... 
</data>

The problem is that when I invoke the method to returns all courses, an error occurs indicating that a parameter is missing, it looks like that it is trying to call the GET method to returns only one.

In the documentation the suggested way is to use singular/plural for this, but I think this is not the best / correct way of doing this.

Any ideia?

Was it helpful?

Solution

I'm afraid, that is a limitation of DSS at the moment, and you cannot use the same base URL to call two different queries, by looking at the parameters. And as you also mentioned, the other approach is to use different resource paths to map to queries.

In the upcoming release of DSS, v3.1.0, the functionality you are looking for will be supported.

Cheers, Anjana.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top