ORDS REST: Getting Bind Variables Right

It seems every time I create a REST GET module I have to re-learn how to handle bind variables. So I decided to create a little cheat sheet.

When creating a REST module with a GET handler, you can pass variables wither through the URI or through header variables:

URI Variables:

URI

The URI template needs to have the bind variables in curly brackets (comma separated if multiple binds):

Create a query:

Create a parameter for each bind variable:
parameters

I don’t think whether if the Source Type matters. HTTP Header has worked for me. I typically set the parameter name and bind variable name to upper case to avoid any problems.

Test:

Click the Set Bind Variables button to test the handler. Make sure to add a value to all parameters. If you leave a parameter empty, you’ll get an error.

 

Header Variables:

Create the URI without a trailing forward slash:

header

Create the query and parameters as before.

Test:

You’ll have to test this with a REST client like POSTman or CURL:

Note when using header variables, you can leave some out without getting an error.

Happy RESTing!

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *