Exposing rest with endpoint.com/person/{var1}/order{var2}

Hello,


Is it possible to expose a rest API with the following structure:

endpoint.com/person/{var1}/order/{var2}/invoice

Where the variables are on the tree structure of the endpoint itself?


As mentioned in some guidelines as resource oriented design:

https://cloud.google.com/apis/design/resources


Thank you & stay safe !

Pedro Abreu

Hi Pedro,

This should be possible, but it's easy to check? Did you try it at all?

Hello Kilian,


Yes, i do not see an option for such implementation.

Although we can specify the URL path, I do not see an option to have parameters as i previously described.



Again, this is about exposing an API, as for consuming it is possible.


Thanks,

Pedro

Solution

But, it's exactly the same way possible for exposing. I don't know what you don't understand.

  1. Expose a REST API;
  2. Add a REST Method;
  3. Add an Input Parameter, set "Receive In" to "URL" (it should be by default);
  4. Put the Input Parameter in the URL Path of the Method, between curly braces.

That's it.


Solution

Hello Kilian,


Thank for such quick reply.

Wasn't aware we could have parameters here:



Thanks again, have a great week !

Pedro Abreu


Glad I could be of help. Happy coding!