8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Misc » Here

Comments for Oracle REST Data Services (ORDS) : Create Basic RESTful Web Services Using PL/SQL


Matthias Rogel said...

Hi Tim,

is there a typo in the page ?
Shouldn't it read
http://ol7-121.localdomain:8080/ords/pdb1/testuser1/testmodule3b/emp&empno_start=7876&empno_end=7934
instead of
http://ol7-121.localdomain:8080/ords/pdb1/testuser1/testmodule3b/emp/?empno_start=7876&empno_end=7934
?
Thanks
Matthias

Tim... said...

Hi.

No. That is correct. The endpoint is "emp/", then you are adding parameters to that.

Cheers

Tim...

Pierre said...

Hi Tim,
do you know how to hide null value in ORDS? Example if deptno is null, just want to hide it, else show it. the SQl/Json handle it with ABSENT ON NULL. The APEX_JSON.WRITE handle it too. Is there a way to make it using just ords?

{
"id": 1,
"ename": "pierre",
"deptno": null
}

Tim... said...

Hi.

Sorry. No idea. I guess you could ask on the ORDS forum. The developers answer questions there, so they should know if it's possible.

Cheers

Tim...

Pierre said...

Hi Tim,

do you know how to make a Post Request with a Image and others Parameters in the :body?

I use ords 17.4

Thanks

Pierre

Tim... said...

Hi.

You would probably have to base64 encode the image in the payload, and pass the whole payload as a blob, then parse it all out internally in your code.

Cheers

Tim...

Pierre said...

Hi Tim,

"parse it all out internally in your code. " Can you help me to do that? Never make it before.

The another alternativ is to set the Others Parameters in the Headers and we use the :body for the Image. Is it okay if we send Others Parameters im Headers and Image im :body?

We have many Parameters to set(about 50)


Thanks

Pierre

Tim... said...

Hi.

Send the whole JSON document (parameters and base64 encoded image) as a single BLOB parameter. Then use PL/SQL to parse it. There are examples of doing this here.

https://oracle-base.com/articles/misc/oracle-rest-data-services-ords-restful-web-services-handling-complex-json-payloads

Cheers

Tim...

John said...

Fantastic and concise explanation of creating APIs with ORDS. Thanks Tim a million times over!!

AZ said...

great example. thank you for putting out.
Shouldn't the date/time be in ISO8601?

Tim... said...

Hi.

Funny that I did the import as and ISO8601 date, but not the output. I've changed that now. :)

All of the examples are just dates with no time components, hence the use of an ISO8601 date, not an ISO8601 datetime.

Cheers

Tim...

Joachim Dostal said...

for executing: BEGIN...ORDS.define_template( p_module_name => 'rest-v3b', p_pattern => 'employees/:empno_start/:empno_end'); ORDS.define_handler( p_module_name => 'rest-v3b', p_pattern => 'employees/',...END; I get error(s)-if changing following: ORDS.define_handler(...p_pattern => 'employees/:empno_start/:empno_end', ...like p_pattern from template it's executeable and working.

Tim... said...

Hi.

Yeah, patterns gotta match. :) Sorry about that. Bad copy/paste from previous example. Fixed now. Thanks.

Cheers

Tim...

Joachim Dostal said...

Wow - thanks for your fast response(+correction) and the cool article! Question: Could you explain, why this "duplicate definition" is needed? Is there a possibilty to define it only one time ?

Tim... said...

Hi.

It's not necessary to do both. They are two different methods to achieve a similar result. They do the same thing, but with different URL patterns. Just pick the one you prefer. :)

http://localhost:8080/ords/hr/rest-v3b/employees/?empno_start=7876&empno_end=7934
http://localhost:8080/ords/hr/rest-v3b/employees/7876/7934

Cheers

Tim...

Naresh Kumar Mallela said...

For inserting multiple rows, do we need to make POST call for each row? How can we insert multiple rows into a table using single POST call. Can you advise

Tim... said...

Hi.

You are writing the service, so it is you that decides how it works. If you want it to handle multiple rows, write a service that can do that. You might find these examples more useful.

https://oracle-base.com/articles/misc/oracle-rest-data-services-ords-restful-web-services-handling-complex-json-payloads

Cheers

Tim...

Too long url said...

Hello,

This was really useful for me thanks

I use this Multi-Value Parameters http://localhost:8080/ords/hr/rest-v3c/employees/7876,7934,7782

It works when url is short but I just got an error 400 Bad Request with tomcat ords when url it's too long

Do you know how can I fix this ?






Tim... said...

Hi.

It varies a little, but the maximum length of a URL is 2000 characters, so you can't use more than that. I don't know if ORDS can cope with a URL that big. For anything large I always use a payload, not the URL.

Cheers

Tim...

DO NOT ask technical questions here! They will be deleted!

These comments should relate to the contents of a specific article. Constructive criticism is good. Advertising and offensive comments are bad and will be deleted!

If you post personal information (name, email address etc.) you are agreeing to them being stored and displayed. Feel free to remain anonymous.