Highlighted

Pass an ID to API Manager Resource

Explorer ,
Feb 19, 2018

Copy link to clipboard

Copied

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?

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.

Views

124

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Pass an ID to API Manager Resource

Explorer ,
Feb 19, 2018

Copy link to clipboard

Copied

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?

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.

Views

125

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 19, 2018 0
Explorer ,
Feb 19, 2018

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 19, 2018 0