Skip to main content
Russ Ortisi
Inspiring
February 19, 2018
Answered

Pass an ID to API Manager Resource

  • February 19, 2018
  • 1 reply
  • 328 views

As it is standard practice to send an ID to RESTful APIs by referring to the object type, followed by the ID...

e.g. http://example.com/products/3484909

would normally bring me back data for the product with ID 3484909.

I can't seem to get API Manager to take this kind of argument, though. It's not a major issue, but it would appear the only thing I can do is call the following:

http://example.com/products?id=3484909 to get the desired result

With many platforms you can specify a variable to accept when identifying a route or resource but it doesn't appear there is any way to do this with API Manager. Has anyone seen anything like this or know a away around it?

This topic has been closed for replies.
Correct answer Russ Ortisi

I figured this one out. If you define a resource as a GET resource, and then define a separate GET resource with the parameterized value, it works. For example, the first resource was defined as follows:

GET => /publications

So, if the user sends a get request to http://example.com/publications this returned all publications. The second one is defined as follows:

GET => /publications/{id}

So, if the user sends a get request to http://example.com/publications/23423 this will now return the data for the publication with that specified ID.

1 reply

Russ Ortisi
Russ OrtisiAuthorCorrect answer
Inspiring
February 19, 2018

I figured this one out. If you define a resource as a GET resource, and then define a separate GET resource with the parameterized value, it works. For example, the first resource was defined as follows:

GET => /publications

So, if the user sends a get request to http://example.com/publications this returned all publications. The second one is defined as follows:

GET => /publications/{id}

So, if the user sends a get request to http://example.com/publications/23423 this will now return the data for the publication with that specified ID.