Please how do I display the response from,this endpoint using the apex webservice make request when I try outputting the response I get the ORA-06502: PL/SQL: numeric or value error. The api I am calling returns a string when I test on postman. Below is my PLSQL code.
declare
j_string clob;
begin
j_string := apex_web_service.make_rest_request(p_url => 'http://localhost/api/public/cerificate', p_http_method => 'POST',
p_body => '{
"name": "Jonh West",
"gender": "Male",
"dob": "sep-02-1977",
"occupation": "Trader",
"address": "NO 33 Mudupe Street Ikeja Lagos",
"mobile": "08131500000",
"email": "[email protected]",
"kinName": "James West",
"kinMobile": "08145600000",
"kinEmail": "[email protected]",
"coverPlan": "BRONZE",
"coverMedical": "20000",
"coverPDisability": "30000",
"coverTDisability": "15000",
"coverDeath": "44000",
"aPremiuum": "80000"
}');
dbms_output.put_line(j_string);
end ;
This is the error I get: ORA-06502: PL/SQL: numeric or value error ORA-06512: at line 23 ORA-06512: at "SYS.DBMS_SQL", line 1721
- declare
- j_string clob;
- begin
- j_string := apex_web_service.make_rest_request(p_url => 'http://localhost/api/public/cerificate', p_http_method => 'POST',
CodePudding user response:
The line number indicates that the error is caused by the dbms_output.put_line
. It is expecting a string but getting a clob value which could be the cause of the error. I would try the following:
dbms_output.put_line(dbms_lob.substr ( j_string, 4000, 1 ));
and see if that works.
On a side note, naming a variable ".._string" while it is actually a CLOB is confusing :)