0
votes

I am using Oracle Apex 20.2.0.00.20 and ORDS to test a first REST service using this tutorial. Instead of the table in the tutorial I used the emp table. It works until the point where I try to POST data to the REST service using curl.

I can successfully GET the url https://myserver:8080/apex/mydb/myschema/emp/ and it returns the row JSON.

I used this curl command from the DOS prompt using curl for DOS to POST data:

curl -X POST -H'Content-Type:application/json' -d'{"ename":"JUSTIN","job":"ANALYST","mgr":7839,"hiredate":"2020-04-30T22:00:00Z","sal":100000,"comm":null,"deptno":30}' https://myserver:8080/apex/mydb/myschema/emp/

This creates a row in the emp table, but all the table columns are null except for the empno column which gets populated via a trigger.

The output from curl is:

{"empno":8003,"ename":null,"job":null,"mgr":null,"hiredate":null,"sal":null,"comm":null,"deptno":null,"links":[{"rel":"self","href":"https://myserver:8080/apex/mydb/myschema/emp/8003"},{"rel":"edit","href":"https://myserver:8080/apex/mydb/myschema/emp/8003"},{"rel":"describedby","href":"https://myserver:8080/apex/mydb/myschema/metadata-catalog/emp/item"},{"rel":"collection","href":"https://myserver:8080/apex/mydb/myschema/emp/"}]}

Also when I send through a job that exceeds the column length it does not fail with status 500, but instead creates the row with nulls again.

Anybody know where the tutorial or I are going wrong?

1
I remember using this example: oracle-base.com/articles/misc/… It worked for me like charm... - Koen Lostrie
Thanks, but looking for Apex automated; and it does not mention Apex 20.2 - Superdooperhero
How is this related to a specific apex version ? ORDS and Apex are different technologies. What you're trying to do is unrelated to apex (at least your example shows no relationship with apex) - Koen Lostrie
The "Web Source Modules" in the tutorial is where it becomes Apex related - what you're trying to do here: a POST to a restful service is ORDS related and does not need apex. You could try running it using a browser extension like Postman instead of using curl (which is a challenge on windows). - Koen Lostrie
So you're using AutoREST table. If you open sql developer web, the REST console gives your the cURL cmd for your post thatjeffsmith.com/archive/2021/01/… - thatjeffsmith

1 Answers

-1
votes

Add -H'Content-Type:application/json' to your curl request.